/* APT Notes — K-pop / Blackpink themed PWA */

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

:root {
    --bg: #0D0D0D;
    --surface: #1A1A1A;
    --surface-hover: #252525;
    --surface-border: #2A2A2A;
    --pink: #FF2D87;
    --pink-glow: rgba(255, 45, 135, 0.25);
    --pink-soft: rgba(255, 45, 135, 0.1);
    --hot-pink: #FF69B4;
    --gold: #FFD700;
    --text: #F5F5F5;
    --text-muted: #888888;
    --text-dim: #555555;
    --coral: #FF6B6B;
    --success: #10B981;
    --radius: 16px;
    --radius-sm: 10px;

    /* Category colors */
    --cat-lecture: #6366F1;
    --cat-clinical: #10B981;
    --cat-study: #F59E0B;
    --cat-lab: #8B5CF6;
    --cat-anatomy: #EF4444;
    --cat-pharma: #06B6D4;
    --cat-radio: #64748B;
    --cat-personal: #EC4899;
    --cat-general: #888888;
    --cat-error: #FF6B6B;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    height: 100%;
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow: hidden;
}

/* ── App Shell ────────────────────────────────────────────── */

#app {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 480px;
    margin: 0 auto;
}

/* ── Header ───────────────────────────────────────────────── */

header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px 12px;
    flex-shrink: 0;
}

.logo {
    font-family: 'Outfit', sans-serif;
    font-weight: 900;
    font-size: 28px;
    letter-spacing: -1px;
    background: linear-gradient(135deg, var(--pink), var(--hot-pink));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo span {
    -webkit-text-fill-color: var(--gold);
    font-size: 14px;
    vertical-align: super;
    margin-left: 2px;
}

.header-actions {
    display: flex;
    gap: 8px;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--surface);
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.icon-btn:hover, .icon-btn.active {
    background: var(--pink-soft);
    color: var(--pink);
}

/* ── Navigation Tabs ──────────────────────────────────────── */

nav {
    display: flex;
    gap: 4px;
    padding: 0 20px 12px;
    flex-shrink: 0;
}

nav button {
    flex: 1;
    padding: 10px 0;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

nav button.active {
    background: var(--pink-soft);
    color: var(--pink);
}

nav button:hover:not(.active) {
    color: var(--text);
}

/* ── Screens ──────────────────────────────────────────────── */

.screen {
    display: none;
    flex: 1;
    overflow-y: auto;
    padding: 0 20px 100px;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

/* ── Record Screen ────────────────────────────────────────── */

#screen-record {
    align-items: center;
    justify-content: center;
    gap: 32px;
    padding-bottom: 60px;
}

.record-label {
    font-family: 'Outfit', sans-serif;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-muted);
    text-align: center;
}

.record-btn {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 4px solid var(--pink);
    background: var(--surface);
    color: var(--pink);
    font-size: 42px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    position: relative;
}

.record-btn::before {
    content: '';
    position: absolute;
    inset: -12px;
    border-radius: 50%;
    border: 2px solid var(--pink-glow);
    animation: none;
}

.record-btn.recording {
    background: var(--pink);
    color: white;
    border-color: var(--pink);
    box-shadow: 0 0 40px var(--pink-glow), 0 0 80px var(--pink-glow);
}

.record-btn.recording::before {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 0.6; }
    50% { transform: scale(1.15); opacity: 0; }
}

.record-timer {
    font-family: 'Outfit', sans-serif;
    font-size: 48px;
    font-weight: 700;
    color: var(--pink);
    letter-spacing: 2px;
    opacity: 0;
    transition: opacity 0.3s;
}

.record-timer.visible {
    opacity: 1;
}

.record-hint {
    color: var(--text-dim);
    font-size: 13px;
    text-align: center;
}

/* ── Processing overlay ───────────────────────────────────── */

.processing-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(13, 13, 13, 0.9);
    z-index: 100;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 24px;
}

.processing-overlay.active {
    display: flex;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--surface-border);
    border-top-color: var(--pink);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.processing-text {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 16px;
}

/* ── Notes List Screen ────────────────────────────────────── */

.filter-bar {
    display: flex;
    gap: 8px;
    padding-bottom: 16px;
    overflow-x: auto;
    flex-shrink: 0;
    -webkit-overflow-scrolling: touch;
}

.filter-bar::-webkit-scrollbar { display: none; }

.filter-chip {
    flex-shrink: 0;
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid var(--surface-border);
    background: transparent;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.filter-chip.active {
    border-color: var(--pink);
    background: var(--pink-soft);
    color: var(--pink);
}

.notes-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.note-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s;
    border-left: 4px solid var(--cat-general);
    animation: slideIn 0.3s ease-out;
}

.note-card:hover {
    background: var(--surface-hover);
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.note-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.note-category {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 3px 8px;
    border-radius: 6px;
    background: var(--pink-soft);
    color: var(--pink);
}

.note-date {
    font-size: 12px;
    color: var(--text-dim);
}

.note-title {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 16px;
    margin-bottom: 6px;
    line-height: 1.3;
}

.note-preview {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.note-meta {
    display: flex;
    gap: 12px;
    margin-top: 10px;
    font-size: 12px;
    color: var(--text-dim);
}

/* ── Note Detail Screen ───────────────────────────────────── */

#screen-detail {
    padding-top: 0;
}

.detail-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0 16px;
    flex-shrink: 0;
}

.back-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--surface);
    color: var(--text);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.detail-title {
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    font-size: 22px;
    flex: 1;
    line-height: 1.2;
}

.detail-actions {
    display: flex;
    gap: 8px;
}

.detail-meta {
    display: flex;
    gap: 16px;
    padding: 12px 0;
    border-top: 1px solid var(--surface-border);
    border-bottom: 1px solid var(--surface-border);
    margin-bottom: 20px;
    flex-shrink: 0;
}

.detail-meta-item {
    font-size: 13px;
    color: var(--text-muted);
}

.detail-meta-item strong {
    color: var(--text);
}

.detail-content {
    font-size: 15px;
    line-height: 1.8;
    color: var(--text);
    white-space: pre-wrap;
    overflow-y: auto;
    flex: 1;
}

.detail-content strong {
    color: var(--pink);
    font-family: 'Outfit', sans-serif;
}

.detail-transcript {
    margin-top: 24px;
    padding: 16px;
    background: var(--surface);
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.detail-transcript-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-dim);
    margin-bottom: 8px;
}

.detail-transcript-text {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.6;
    font-style: italic;
}

/* ── Ask Screen ───────────────────────────────────────────── */

#screen-ask {
    padding-bottom: 80px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-bottom: 16px;
}

.chat-bubble {
    max-width: 90%;
    padding: 14px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    line-height: 1.6;
    animation: slideIn 0.3s ease-out;
}

.chat-bubble.user {
    align-self: flex-end;
    background: var(--pink);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-bubble.assistant {
    align-self: flex-start;
    background: var(--surface);
    color: var(--text);
    border-bottom-left-radius: 4px;
    white-space: pre-wrap;
}

.chat-input-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px 20px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    background: var(--bg);
    border-top: 1px solid var(--surface-border);
    display: flex;
    gap: 8px;
    max-width: 480px;
    margin: 0 auto;
}

.chat-input {
    flex: 1;
    padding: 12px 16px;
    border-radius: 24px;
    border: 1px solid var(--surface-border);
    background: var(--surface);
    color: var(--text);
    font-size: 15px;
    font-family: 'Inter', sans-serif;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input:focus {
    border-color: var(--pink);
}

.chat-input::placeholder {
    color: var(--text-dim);
}

.chat-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: var(--pink);
    color: white;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
}

.chat-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ── Settings Screen ──────────────────────────────────────── */

#screen-settings {
    gap: 16px;
}

.settings-group {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px;
}

.settings-group h3 {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 15px;
    margin-bottom: 12px;
    color: var(--text);
}

.settings-field {
    margin-bottom: 16px;
}

.settings-field:last-child {
    margin-bottom: 0;
}

.settings-field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.settings-field input {
    width: 100%;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--surface-border);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    outline: none;
}

.settings-field input:focus {
    border-color: var(--pink);
}

.btn {
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    border: none;
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-pink {
    background: var(--pink);
    color: white;
}

.btn-pink:hover {
    box-shadow: 0 0 20px var(--pink-glow);
}

.btn-outline {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--surface-border);
}

.btn-danger {
    background: transparent;
    color: var(--coral);
    border: 1px solid var(--coral);
}

.btn-block {
    width: 100%;
}

/* ── Record Mascot ───────────────────────────────────────── */

.record-mascot {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: -8px;
    filter: drop-shadow(0 0 20px var(--pink-glow));
}

/* ── Empty State ──────────────────────────────────────────── */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    gap: 12px;
}

.empty-img {
    width: 180px;
    height: 180px;
    border-radius: 24px;
    object-fit: cover;
    filter: drop-shadow(0 0 16px var(--pink-glow));
}

.empty-icon {
    font-size: 56px;
    opacity: 0.3;
}

.empty-text {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    font-size: 18px;
    color: var(--text-muted);
}

.empty-hint {
    font-size: 14px;
    color: var(--text-dim);
}

/* ── Toast ────────────────────────────────────────────────── */

.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    padding: 12px 24px;
    border-radius: 24px;
    background: var(--surface);
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    z-index: 200;
    transition: transform 0.3s ease-out;
    white-space: nowrap;
}

.toast.visible {
    transform: translateX(-50%) translateY(0);
}

.toast.error {
    border: 1px solid var(--coral);
}

.toast.success {
    border: 1px solid var(--success);
}

/* ── Install Banner ───────────────────────────────────────── */

.install-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 14px 20px;
    padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    background: var(--surface);
    border-top: 1px solid var(--pink);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 150;
    max-width: 480px;
    margin: 0 auto;
    animation: slideIn 0.3s ease-out;
}

.install-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.install-text strong {
    font-family: 'Outfit', sans-serif;
    font-size: 15px;
    color: var(--text);
}

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

.install-dismiss {
    width: 32px;
    height: 32px;
    border: none;
    background: none;
    color: var(--text-dim);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── Scrollbar ────────────────────────────────────────────── */

::-webkit-scrollbar {
    width: 4px;
}

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

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

/* ── Responsive safe area ─────────────────────────────────── */

@supports (padding: env(safe-area-inset-bottom)) {
    #app {
        padding-bottom: env(safe-area-inset-bottom);
    }
}
