@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

/* ─── Reset ──────────────────────────────────────────────────────────────── */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ─── Design tokens ──────────────────────────────────────────────────────── */
:root {
    --bg: #09090b;
    --surface: #18181b;
    --surface-2: #27272a;
    --surface-3: #3f3f46;
    --border: #27272a;
    --border-soft: #1e1e21;

    --text: #fafafa;
    --text-2: #a1a1aa;
    --text-3: #71717a;

    --accent: #fafafa;
    /* Bright white/zinc accent */
    --accent-dim: rgba(250, 250, 250, 0.1);
    --accent-hover: rgba(250, 250, 250, 0.15);

    --danger: #ef4444;
    --danger-dim: rgba(239, 68, 68, 0.12);

    --radius-sm: 4px;
    --radius: 6px;
    --radius-lg: 8px;

    --toolbar-h: 48px;
    --status-h: 28px;
    --sidebar-w: 260px;

    --shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);

    --transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── Base ───────────────────────────────────────────────────────────────── */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 13px;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ─── Toolbar ────────────────────────────────────────────────────────────── */
.toolbar {
    height: var(--toolbar-h);
    min-height: var(--toolbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 0 10px;
    z-index: 100;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    /* Firefox */
}

.toolbar::-webkit-scrollbar {
    display: none;
    /* Chrome/Safari */
}

.toolbar-sep {
    width: 1px;
    height: 20px;
    background: var(--border);
    margin: 0 4px;
    flex-shrink: 0;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

/* ─── Buttons (base) ─────────────────────────────────────────────────────── */
button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    height: 30px;
    padding: 0 10px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-2);
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    flex-shrink: 0;
}

button:hover {
    background: var(--surface-3);
    color: var(--text);
    border-color: var(--border);
}

button:active {
    background: var(--surface-2);
}

/* Primary — upload */
button.primary {
    background: var(--accent);
    color: var(--bg);
    border-color: transparent;
    font-weight: 600;
    padding: 0 12px;
}

button.primary:hover {
    background: var(--text);
    color: var(--bg);
}

/* Active tool */
button.active,
button.tool-btn.active {
    background: var(--accent-dim);
    border-color: var(--accent);
    color: var(--accent);
}

/* Icon-only button */
.icon-btn {
    width: 28px;
    height: 28px;
    padding: 0;
    font-size: 13px;
}

/* Sidebar secondary action button */
.secondary-btn {
    width: 100%;
    height: 32px;
    justify-content: center;
    background: var(--surface-2);
    border-color: var(--border);
    color: var(--text-2);
    font-size: 12px;
    border-radius: var(--radius-sm);
}

.secondary-btn:hover {
    background: var(--surface-3);
    border-color: var(--border);
    color: var(--text);
}

/* ─── Tool buttons ───────────────────────────────────────────────────────── */
.tool-btn {
    padding: 0 10px;
    font-size: 12px;
    letter-spacing: 0.01em;
}

/* Vertical Toolbar */
.vertical-toolbar {
    width: 64px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 0;
    gap: 8px;
    z-index: 50;
    flex-shrink: 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.vertical-toolbar::-webkit-scrollbar {
    display: none;
}

.tool-btn-v {
    width: 48px;
    height: 48px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border-radius: var(--radius);
    background: transparent;
    color: var(--text-2);
    border: 1px solid transparent;
    transition: var(--transition);
    cursor: pointer;
    padding: 0;
}

.tool-btn-v:hover {
    background: var(--surface-3);
    color: var(--text);
}

.tool-btn-v.active {
    background: var(--accent-dim);
    color: var(--accent);
    border-color: var(--accent);
}

.t-icon {
    font-size: 16px;
    line-height: 1;
}

.t-label {
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.toolbar-sep-v {
    width: 24px;
    height: 1px;
    background: var(--border);
    margin: 4px 0;
    flex-shrink: 0;
}

/* ─── Scale control ──────────────────────────────────────────────────────── */
.scale-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0 4px;
}

.scale-select {
    height: 30px;
    padding: 0 28px 0 8px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: inherit;
    font-size: 12px;
    min-width: 145px;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23555d70'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
}

.scale-select:focus {
    outline: none;
    border-color: var(--accent);
}

.scale-select option {
    background: var(--surface-2);
    color: var(--text);
}

.scale-select optgroup {
    color: var(--text-3);
    background: var(--surface-2);
}

#custom-scale-container {
    display: none;
    align-items: center;
    gap: 4px;
}

.scale-input {
    width: 52px;
    height: 30px;
    padding: 0 6px;
    text-align: center;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: inherit;
    font-size: 12px;
}

.scale-input:focus {
    outline: none;
    border-color: var(--accent);
}

.scale-units {
    height: 30px;
    padding: 0 6px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: inherit;
    font-size: 12px;
}

.scale-unit {
    font-size: 12px;
    color: var(--text-3);
}

#calibrate-btn {
    padding: 0 10px;
    font-size: 12px;
}

/* ─── Zoom / page navigation ─────────────────────────────────────────────── */
.zoom-level {
    min-width: 46px;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-2);
}

.page-input {
    width: 40px;
    height: 30px;
    padding: 0 4px;
    text-align: center;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: inherit;
    font-size: 12px;
}

.page-input:focus {
    outline: none;
    border-color: var(--accent);
}

/* ─── Bookmark star button ───────────────────────────────────────────────── */
#bookmark-star-btn {
    font-size: 16px;
    color: var(--text-3);
    width: 30px;
    height: 30px;
    padding: 0;
    transition: var(--transition);
}

#bookmark-star-btn:hover {
    color: var(--text);
    background: var(--surface-3);
}

#bookmark-star-btn.bookmarked {
    color: #c4a35a;
    background: transparent;
    border-color: transparent;
}

#bookmark-star-btn.bookmarked:hover {
    color: #d4b36a;
    background: var(--surface-3);
}

/* ─── Main layout ────────────────────────────────────────────────────────── */
.main-container {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
}

/* ─── Sidebar ────────────────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    display: flex;
    flex-direction: column;
    transition: all 0.2s ease;
    z-index: 10;
    border: none;
    flex-shrink: 0;
}

.left-sidebar {
    border-right: 1px solid var(--border);
    transform: translateX(-100%);
    position: absolute;
    height: 100%;
    left: 65px;
    width: 0;
    overflow: hidden;
    z-index: 40;
}

.left-sidebar.active {
    transform: translateX(0);
    position: absolute;
    left: 65px;
    width: var(--sidebar-w);
    overflow: visible;
}

.right-sidebar {
    border-left: 1px solid var(--border);
    transform: translateX(100%);
    position: absolute;
    right: 0;
    height: 100%;
    width: 0;
    overflow: hidden;
    z-index: 40;
}

.right-sidebar.active {
    transform: translateX(0);
    position: absolute;
    right: 0;
    width: var(--sidebar-w);
    overflow: visible;
}

.sidebar-header {
    height: 44px;
    padding: 0 14px;
    border-bottom: 1px solid var(--border-soft);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

/* ─── Pages Panel / Thumbnails ─────────────────────────────────────────── */
.thumbnails-grid {
    display: grid;
    gap: 12px;
    padding: 12px;
    overflow-y: auto;
    height: 100%;
    align-content: start;
}

.thumbnails-grid[data-columns="1"] {
    grid-template-columns: 1fr;
}

.thumbnails-grid[data-columns="2"] {
    grid-template-columns: 1fr 1fr;
}

.thumbnails-grid[data-columns="3"] {
    grid-template-columns: repeat(3, 1fr);
}

.thumbnails-grid[data-columns="4"] {
    grid-template-columns: repeat(4, 1fr);
}

.thumbnail-wrapper {
    position: relative;
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 20px;
    transition: var(--transition);
    background: var(--surface-2);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 6px;
}

.thumbnail-wrapper:hover {
    border-color: var(--border-hover);
}

.thumbnail-wrapper.active {
    border-color: var(--accent);
    background: rgba(79, 142, 247, 0.1);
}

.thumb-canvas-container {
    width: 100%;
    aspect-ratio: 8.5 / 11;
    /* standard page placeholder aspect */
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.thumb-canvas-container canvas {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.thumbnail-wrapper.bookmarked .thumb-star {
    opacity: 1;
    color: #c4a35a;
}

.thumb-star {
    position: absolute;
    top: 8px;
    left: 14px;
    font-size: 16px;
    color: transparent;
    text-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
    transition: var(--transition);
    z-index: 2;
}

.thumb-indicators {
    position: absolute;
    bottom: 4px;
    right: 4px;
    display: flex;
    gap: 4px;
    z-index: 2;
}

.thumb-icon {
    font-size: 10px;
    line-height: 1;
    background: rgba(0, 0, 0, 0.7);
    color: #22c55e;
    /* scaled/measurements indicator */
    padding: 3px;
    border-radius: 2px;
}

.thumb-label {
    text-align: center;
    font-size: 11px;
    color: var(--text-2);
    margin-top: 6px;
    font-weight: 500;
}

.sidebar-header h3 {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.sidebar-footer {
    padding: 10px 12px;
    border-top: 1px solid var(--border-soft);
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

/* ─── Bookmarks list ─────────────────────────────────────────────────────── */
.bookmarks-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.bookmark-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    background: var(--surface-2);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.bookmark-item:hover {
    background: var(--surface-3);
    border-color: var(--border);
}

.bookmark-item.active {
    background: var(--accent-dim);
    border-color: var(--accent);
}

.bookmark-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.bookmark-page {
    font-size: 11px;
    font-weight: 700;
    color: var(--accent);
    min-width: 32px;
}

.bookmark-name {
    font-size: 13px;
    color: var(--text-2);
    cursor: pointer;
    transition: color 0.2s ease;
}

.bookmark-name:hover {
    color: var(--text);
    text-decoration: underline;
}

.bookmark-remove {
    width: 22px;
    height: 22px;
    font-size: 11px;
    color: var(--text-3);
    opacity: 0.6;
    flex-shrink: 0;
}

.bookmark-remove:hover {
    opacity: 1;
    color: var(--danger);
    background: var(--danger-dim);
    border-color: transparent;
}

/* ─── Measurements ───────────────────────────────────────────────────────── */
.measurement-summary {
    background: var(--surface-2);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    padding: 12px;
    margin-bottom: 10px;
}

.summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 3px 0;
}

.summary-label {
    font-size: 11px;
    color: var(--text-3);
}

.summary-value {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.measurements-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.measurement-item {
    background: var(--surface-2);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 9px 10px;
    cursor: pointer;
    transition: var(--transition);
}

.measurement-item:hover {
    background: var(--surface-3);
    border-color: var(--border);
}

.measurement-item.active {
    background: var(--accent-dim);
    border-color: var(--accent);
}

.measurement-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.measurement-type {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.measurement-delete {
    width: 20px;
    height: 20px;
    font-size: 11px;
    color: var(--text-3);
    opacity: 0.5;
}

.measurement-delete:hover {
    opacity: 1;
    color: var(--danger);
    background: var(--danger-dim);
    border-color: transparent;
}

.measurement-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.measurement-page {
    font-size: 10px;
    color: var(--text-3);
    margin-top: 3px;
}

/* ─── Empty state ────────────────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    color: var(--text-3);
    padding: 28px 16px;
    font-size: 12px;
    line-height: 1.7;
}

/* ─── Canvas area ────────────────────────────────────────────────────────── */
.canvas-container {
    position: relative;
    flex: 1;
    background: var(--bg);
    overflow: auto;
    cursor: default;
}

#pdf-canvas,
#drawing-canvas {
    position: absolute;
    top: 0;
    left: 0;
    display: block;
    box-shadow: var(--shadow-lg);
}

#pdf-canvas {
    z-index: 1;
}

#drawing-canvas {
    z-index: 2;
    pointer-events: none;
}

/* ─── Status bar ──────────────────────────────────────────────────────────── */
.status-bar {
    height: var(--status-h);
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 0 14px;
    font-size: 11px;
    color: var(--text-3);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    z-index: 100;
    flex-shrink: 0;
}

.status-right {
    display: flex;
    gap: 18px;
    align-items: center;
}

#active-tool {
    font-size: 11px;
    font-weight: 600;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* ─── Bookmark filled star in status bar ─────────────────────────────────── */
.bookmark-indicator {
    font-size: 13px;
    color: #c4a35a;
}

/* ─── Loading toast (non-blocking) ─────────────────────────────── */
.loading-toast {
    position: fixed;
    bottom: 36px;
    /* just above status bar */
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background: var(--surface);
    color: var(--text-2);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 6px 18px;
    font-size: 12px;
    font-weight: 500;
    box-shadow: var(--shadow);
    pointer-events: none;
    /* never blocks interaction */
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 2000;
    white-space: nowrap;
}

.loading-toast::before {
    content: 'Rendering…';
}

.loading-toast.active {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ─── Scrollbars ─────────────────────────────────────────────────────────── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--surface-3);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border);
}

/* ── Groups Panel ────────────────────────────────────────────── */
.group-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: var(--transition);
}

.group-item:hover {
    background: var(--surface-2);
    border-color: var(--border);
}

.group-item.active {
    border-color: var(--accent);
    background: var(--surface-2);
}

.group-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

/* Color swatch that wraps a hidden color input */
.group-color-swatch {
    position: relative;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    flex-shrink: 0;
    cursor: pointer;
    border: 1.5px solid rgba(255, 255, 255, 0.22);
    overflow: hidden;
}

.color-input-hidden {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
    border: none;
    padding: 0;
}

.group-name {
    flex: 1;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text);
}

.group-actions {
    display: flex;
    gap: 2px;
}

.group-icon {
    font-size: 13px;
    color: var(--text-3);
    cursor: pointer;
    padding: 3px 5px;
    border-radius: 4px;
    transition: var(--transition);
}

.group-icon:hover {
    color: var(--text);
    background: var(--surface-3);
}

.group-icon.danger:hover {
    color: var(--danger);
    background: var(--danger-dim);
}

.group-stats {
    font-size: 11px;
    color: var(--text-3);
    padding-left: 24px;
}

/* ── Measurement Group Headers (in measurements list) ────────── */
.mgroup-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 10px;
    margin: 10px 0 4px 0;
    background: var(--surface-3);
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 700;
    color: var(--text);
    /* full bright white */
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.mgroup-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.mgroup-name {
    flex: 1;
}

.mgroup-count {
    font-size: 11px;
    font-weight: 600;
    background: var(--accent-dim);
    color: var(--accent);
    padding: 1px 7px;
    border-radius: 10px;
    border: 1px solid rgba(79, 142, 247, 0.25);
}

/* ── Tool Popup ───────────────────────────────────────────────── */
.tool-popup {
    position: fixed;
    z-index: 9999;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 0;
    min-width: 270px;
    box-shadow: var(--shadow-lg);
    animation: popupIn 0.12s ease;
    overflow: hidden;
}

@keyframes popupIn {
    from {
        opacity: 0;
        transform: translateY(-6px) scale(0.97);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.tp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px 10px 14px;
    border-bottom: 1px solid var(--border-soft);
    background: var(--surface-2);
}

.tp-title {
    font-size: 12px;
    color: var(--text-2);
}

.tp-title strong {
    color: var(--text);
    font-weight: 600;
    text-transform: capitalize;
}

.tp-close {
    width: 22px;
    height: 22px;
    padding: 0;
    font-size: 11px;
    color: var(--text-3);
}

.tp-section {
    padding: 10px 14px 6px 14px;
}

.tp-label {
    display: block;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    margin-bottom: 7px;
}

.tp-color-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.tp-swatch {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.1s ease, border-color 0.1s ease;
    flex-shrink: 0;
}

.tp-swatch:hover {
    transform: scale(1.15);
}

.tp-swatch.selected {
    border-color: #ffffff;
    box-shadow: 0 0 0 2px var(--accent);
    transform: scale(1.1);
}

.tp-color-input {
    width: 32px;
    height: 22px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    cursor: pointer;
    padding: 0;
    vertical-align: middle;
}

.tp-select {
    width: 100%;
    height: 30px;
    padding: 0 8px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
}

.tp-select:focus {
    outline: none;
    border-color: var(--accent);
}

.tp-new-group {
    padding: 0 14px 10px 14px;
}

.tp-text-input {
    width: 100%;
    height: 30px;
    padding: 0 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: inherit;
    font-size: 12px;
}

.tp-text-input:focus {
    outline: none;
    border-color: var(--accent);
}

.tp-footer {
    display: flex;
    gap: 8px;
    padding: 10px 14px;
    border-top: 1px solid var(--border-soft);
    background: var(--surface-2);
}

.tp-btn {
    flex: 1;
    height: 30px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: var(--transition);
}

.tp-btn-sec {
    background: var(--surface-3);
    color: var(--text-2);
    border-color: var(--border);
}

.tp-btn-sec:hover {
    background: var(--surface);
    color: var(--text);
}

.tp-btn-primary {
    background: var(--accent);
    color: var(--bg);
    font-weight: 600;
}

.tp-btn-primary:hover {
    background: var(--text-2);
    color: var(--bg);
}

/* ── Custom Measurement Items ───────────────────────────────── */
.type-badge {
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.5px;
    padding: 2px 5px;
    background: var(--surface-3);
    color: var(--text-2);
    border-radius: 3px;
    text-transform: uppercase;
}

.measurement-details {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

.page-pill {
    font-size: 10px;
    color: var(--text-3);
}

/* ── Measurement Items ────────────────────────────────────────── */
.measurement-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    margin-bottom: 6px;
    cursor: pointer;
    transition: var(--transition);
}

.measurement-item:hover {
    background: var(--surface-2);
}

.measurement-item.active {
    background: var(--surface-2);
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent-dim);
}

.measurement-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.measurement-value {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    /* bright white */
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Measurement list container ───────────────────────────────── */
.measurements-list {
    padding: 2px 0;
}

/* ── Pan tool cursor ──────────────────────────────────────────── */
#tool-pan.active {
    background: rgba(255, 220, 100, 0.12);
    color: #ffd864;
    border-color: rgba(255, 216, 100, 0.3);
}

/* ── Canvas container & placeholder ──────────────────────────── */
.canvas-container {
    flex: 1;
    position: relative;
    overflow: auto;
    background: var(--bg);
}

/* Placeholder shown when no file is open */
.canvas-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    color: var(--text-3);
    user-select: none;
    z-index: 10;
}

.placeholder-icon {
    font-size: 56px;
    opacity: 0.3;
    line-height: 1;
}

.placeholder-title {
    font-size: 22px;
    font-weight: 600;
    color: var(--text-2);
    letter-spacing: -0.01em;
}

.placeholder-sub {
    font-size: 13px;
    color: var(--text-3);
    max-width: 280px;
    text-align: center;
    line-height: 1.6;
}

.placeholder-btn {
    height: 38px;
    padding: 0 22px;
    font-size: 13px;
    font-weight: 600;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    margin-top: 6px;
}

.placeholder-btn:hover {
    background: var(--surface-3);
    border-color: var(--text-3);
    color: var(--text);
}

.placeholder-hint {
    font-size: 11px;
    color: var(--text-3);
    opacity: 0.6;
}

/* ── Calibrate tool highlight ─────────────────────────────────── */
#tool-calibrate.active,
button[id="calibrate-btn"].active {
    background: rgba(34, 197, 94, 0.12);
    color: #22c55e;
    border-color: rgba(34, 197, 94, 0.3);
}

/* ── Modals ─────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(2px);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 320px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.modal h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin: 0;
}

.modal p {
    font-size: 13px;
    color: var(--text-2);
    margin: 0 0 8px 0;
    line-height: 1.4;
}

.modal-inputs {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.calib-input,
.calib-select {
    height: 36px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    padding: 0 10px;
    font-family: inherit;
    font-size: 13px;
}

.calib-input:focus,
.calib-select:focus {
    outline: none;
    border-color: var(--accent);
}

.calib-input {
    flex: 1;
    min-width: 0;
}

.calib-select {
    width: 120px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.modal-footer button {
    height: 36px;
    padding: 0 16px;
    border-radius: var(--radius-sm);
}

.tp-btn-sec {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-2);
}

.tp-btn-sec:hover {
    background: var(--surface-2);
    color: var(--text);
}

.tp-btn-primary {
    background: var(--accent);
    color: var(--bg);
    border: 1px solid transparent;
}

.tp-btn-primary:hover {
    background: var(--text);
}