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

/* ─── Design Tokens (Apple-inspired) ────────────────────────────────────── */
:root {
    --bg: #f2f2f7;
    --surface: rgba(255, 255, 255, 0.82);
    --surface-solid: #ffffff;
    --surface2: rgba(242, 242, 247, 0.9);
    --border: rgba(0, 0, 0, 0.10);

    /* Apple system colours */
    --blue: #007aff;
    --teal: #32ade6;
    --green: #34c759;
    --red: #ff3b30;
    --orange: #ff9500;
    --gray: #8e8e93;
    --gray3: #c7c7cc;
    --gray4: #d1d1d6;
    --gray5: #e5e5ea;

    --text: #1c1c1e;
    --text-sec: #3c3c43;
    --text-ter: #8e8e93;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.10), 0 1px 4px rgba(0, 0, 0, 0.06);
}

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

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

/* ─── Header ─────────────────────────────────────────────────────────────── */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    height: 52px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    z-index: 20;
    flex-shrink: 0;
    gap: 16px;
}

.logo {
    font-size: 15px;
    font-weight: 600;
    color: var(--blue);
    letter-spacing: -0.01em;
    display: flex;
    align-items: center;
    gap: 7px;
    white-space: nowrap;
}

.logo-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--blue);
    box-shadow: 0 0 0 2px rgba(0, 122, 255, 0.2);
}

.toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
}

.tool-group {
    display: flex;
    align-items: center;
    background: var(--gray5);
    border-radius: 12px;
    padding: 3px;
    gap: 2px;
}

.tool-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    border: none;
    background: transparent;
    color: var(--text-sec);
    border-radius: 9px;
    cursor: pointer;
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 500;
    letter-spacing: -0.01em;
    transition: background 0.14s, color 0.14s, box-shadow 0.14s;
    white-space: nowrap;
    user-select: none;
}

.tool-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text);
}

.tool-btn.active {
    background: var(--surface-solid);
    color: var(--blue);
    box-shadow: var(--shadow-sm);
}

.tool-btn.danger {
    color: var(--text-ter);
}

.tool-btn.danger:hover {
    background: rgba(255, 59, 48, 0.08);
    color: var(--red);
}

.tool-sep {
    width: 8px;
}

.stats-pill {
    font-size: 11.5px;
    font-weight: 500;
    color: var(--text-ter);
    background: var(--gray5);
    border-radius: 20px;
    padding: 4px 13px;
}

/* ─── Canvas ──────────────────────────────────────────────────────────────── */
#canvas-wrap {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: radial-gradient(circle at 20% 30%, rgba(0, 122, 255, 0.04) 0%, transparent 55%),
    radial-gradient(circle at 80% 70%, rgba(50, 173, 230, 0.04) 0%, transparent 55%),
    var(--bg);
}

#canvas-wrap::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: radial-gradient(circle, var(--gray4) 1px, transparent 1px);
    background-size: 28px 28px;
    opacity: 0.5;
    pointer-events: none;
}

svg#canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    cursor: default;
}

/* ─── Label input ─────────────────────────────────────────────────────────── */
#label-input {
    position: fixed;
    display: none;
    z-index: 100;
    background: var(--surface-solid);
    border: 1.5px solid var(--blue);
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    padding: 5px 10px;
    border-radius: 8px;
    outline: none;
    min-width: 90px;
    max-width: 220px;
    box-shadow: var(--shadow-md), 0 0 0 3px rgba(0, 122, 255, 0.14);
}

/* ─── Status bar ──────────────────────────────────────────────────────────── */
#status-bar {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 7px 18px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-ter);
    pointer-events: none;
    z-index: 10;
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow-sm);
    white-space: nowrap;
}

#status-bar .key {
    color: var(--blue);
    font-weight: 600;
}

#status-bar .sep {
    color: var(--gray3);
    margin: 0 6px;
}
