@import url('https://fonts.googleapis.com/css2?family=Permanent+Marker&display=swap');

/* Settings Page */

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

/* Restore text cursor only for actual text inputs */
input[type="text"], input[type="search"], input[type="password"],
input[type="email"], input[type="url"], input[type="number"],
input:not([type]), textarea { cursor: text; }

:root {
    --bg: #f2f2f7;
    --surface: #ffffff;
    --surface2: #f2f2f7;
    --border: #e0e0e5;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.07), 0 0 0 1px rgba(0,0,0,0.04);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.08), 0 0 0 1px rgba(0,0,0,0.04);
    --text: #1c1c1e;
    --text-muted: #6b6b70;
    --accent: #d4622a;
    --accent-dim: rgba(212, 98, 42, 0.1);
    --radius: 12px;
    --header-h: 52px;
    --nav-h: 56px;
}

/* ── Dark mode ──────────────────────────────────────────────────────────── */
[data-theme="dark"] {
    --bg: #111113;
    --surface: #1c1c1e;
    --surface2: #252528;
    --border: #38383a;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.04);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.04);
    --text: #f2f2f7;
    --text-muted: #98989e;
    --accent: #e0723a;
    --accent-dim: rgba(224, 114, 58, 0.15);
}

html, body {
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

body {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    overflow: hidden;
}

/* ── Header ─────────────────────────────────────────────── */
.sm-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--header-h);
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    display: flex;
    align-items: center;
    padding: 0 12px;
    z-index: 100;
    gap: 8px;
}

.sm-header-back {
    background: none;
    border: none;
    font-size: 22px;
    color: var(--accent);
    padding: 4px 8px 4px 0;
    line-height: 1;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    text-decoration: none;
    display: flex;
    align-items: center;
}

.app-logo {
    width: 26px;
    height: 29px;
    flex-shrink: 0;
}

.app-name {
    font-family: 'Permanent Marker', cursive;
    font-size: 17px;
    color: var(--accent);
    white-space: nowrap;
    letter-spacing: 0.3px;
    flex-shrink: 0;
    line-height: 1;
}

.sm-header-title {
    font-size: 17px;
    font-weight: 700;
    flex: 1;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sm-header-right {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
}

/* ── Theme toggle button ─────────────────────────────────────────────────── */
.sm-theme-toggle {
    background: none;
    border: none;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 8px;
    color: var(--text-muted);
    -webkit-tap-highlight-color: transparent;
    transition: color 0.15s;
}
.sm-theme-toggle:active { opacity: 0.7; }
/* Sun in light mode, moon in dark */
.sm-theme-toggle::before { content: '\263D'; }
[data-theme="dark"] .sm-theme-toggle::before { content: '\2600'; }

/* Dark mode header/nav overrides */
[data-theme="dark"] .sm-header {
    background: var(--surface);
    border-bottom-color: var(--border);
}
[data-theme="dark"] .sm-nav {
    background: var(--surface);
    border-top-color: var(--border);
}

/* ── Main content ─────────────────────────────────────────── */
.settings-main {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: calc(var(--header-h) + 16px) 16px calc(var(--nav-h) + 24px);
}

/* ── Settings sections ────────────────────────────────────── */
.settings-section {
    margin-bottom: 32px;
}

.settings-section-title {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 10px;
    padding-left: 4px;
}

/* ── Account card ─────────────────────────────────────────── */
.account-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 12px;
}

.account-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--accent-dim);
    flex-shrink: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    font-size: 20px;
    font-weight: 700;
}

.account-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.account-info {
    flex: 1;
    min-width: 0;
}

.account-name {
    font-size: 16px;
    font-weight: 700;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.account-email {
    font-size: 13px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.signout-btn {
    width: 100%;
    padding: 12px;
    background: none;
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    color: var(--accent);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s ease, transform 0.1s ease;
}

.signout-btn:hover {
    background: var(--accent-dim);
}

.signout-btn:active {
    transform: scale(0.98);
}

/* ── Instrument cards ─────────────────────────────────────── */
.instrument-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
}

.instrument-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 20px 12px;
    min-height: 120px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease, transform 0.1s ease;
    outline: none;
}

.instrument-card:hover {
    box-shadow: var(--shadow-md);
}

.instrument-card:active {
    transform: scale(0.97);
}

.instrument-card.selected {
    border-color: var(--accent);
    background: var(--accent-dim);
    box-shadow: var(--shadow-md);
}

.instrument-icon {
    width: 48px;
    height: 48px;
    color: var(--text-muted);
    transition: color 0.2s ease;
}

.instrument-card.selected .instrument-icon {
    color: var(--accent);
}

.instrument-label {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    transition: color 0.2s ease;
}

.instrument-card.selected .instrument-label {
    color: var(--accent);
}

/* ── Theme cards ──────────────────────────────────────────── */
.theme-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.theme-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px 8px;
    min-height: 90px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease, transform 0.1s ease;
    outline: none;
}

.theme-card:hover { box-shadow: var(--shadow-md); }
.theme-card:active { transform: scale(0.97); }

.theme-card.selected {
    border-color: var(--accent);
    background: var(--accent-dim);
    box-shadow: var(--shadow-md);
}

.theme-icon {
    width: 28px;
    height: 28px;
    color: var(--text-muted);
    transition: color 0.2s ease;
}

.theme-card.selected .theme-icon { color: var(--accent); }

.theme-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    transition: color 0.2s ease;
}

.theme-card.selected .theme-label { color: var(--accent); }

/* ── Spotify card ────────────────────────────────────────── */
.spotify-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.spotify-logo {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    color: #1DB954;
}

.spotify-info {
    flex: 1;
    min-width: 0;
}

.spotify-status {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
}

.spotify-sub {
    font-size: 12px;
    color: var(--text-muted);
}

.spotify-action-btn {
    padding: 8px 16px;
    background: #1DB954;
    color: #fff;
    border: none;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: opacity 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.spotify-action-btn:active { opacity: 0.8; }

.spotify-action-btn.connected {
    background: var(--surface2);
    color: var(--text-muted);
    pointer-events: none;
}

/* ── Welcome overlay (first-time onboarding) ─────────────── */
.welcome-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 300;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: calc(var(--header-h) + 8px);
}

.welcome-content {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px 24px;
    box-shadow: var(--shadow-md);
    text-align: center;
    max-width: 320px;
    width: 90%;
    animation: welcome-slide 0.3s ease-out;
}

@keyframes welcome-slide {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.welcome-title {
    font-size: 22px;
    font-weight: 800;
    margin-bottom: 4px;
}

.welcome-sub {
    font-size: 14px;
    color: var(--text-muted);
}

/* ── Toast ────────────────────────────────────────────────── */
.settings-toast {
    position: fixed;
    bottom: calc(var(--nav-h) + 20px);
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background: var(--text);
    color: var(--bg);
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
    z-index: 200;
}

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

.hidden { display: none !important; }

/* ── Bottom Nav ──────────────────────────────────────────── */
.sm-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: var(--nav-h);
    background: var(--bg);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.sm-nav-btn {
    flex: 1;
    background: none;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 0;
    color: var(--text-muted);
    font: inherit;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.15s;
    cursor: pointer;
    text-decoration: none;
}

.sm-nav-btn.active { color: var(--accent); }
.sm-nav-btn:active { opacity: 0.7; }

/* SVG icons — stroke only, bolder when active */
svg.sm-nav-icon {
    width: 24px;
    height: 24px;
    stroke-width: 1.5;
    transition: stroke-width 0.2s ease, transform 0.15s ease;
}

.sm-nav-btn.active svg.sm-nav-icon {
    stroke-width: 2.5;
}

.sm-nav-btn:active svg.sm-nav-icon {
    transform: scale(0.9);
}

.sm-nav-label { font-size: 10px; font-weight: 600; letter-spacing: 0.3px; text-transform: uppercase; }

/* ── Desktop max-width ────────────────────────────────────── */
@media (min-width: 600px) {
    .settings-main {
        max-width: 480px;
        margin: 0 auto;
    }
}
