:root {
    --bg: #0f172a;
    --surface: #1e293b;
    --surface2: #263347;
    --primary: #38bdf8;
    --primary-muted: rgba(56, 189, 248, 0.12);
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --success: #22c55e;
    --danger: #ef4444;
    --card-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.4);
    --bubble-left: #334155;
    --bubble-right: #075e54;
    --header-height: 48px;
    --tabbar-height: 64px;
}

body.light-mode {
    --bg: #f1f5f9;
    --surface: #ffffff;
    --surface2: #e2e8f0;
    --primary: #0284c7;
    --primary-muted: rgba(2, 132, 199, 0.1);
    --text: #0f172a;
    --text-muted: #64748b;
    --card-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.08);
    --bubble-left: #e2e8f0;
    --bubble-right: #dcf8c6;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    outline: none;
}

html,
body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: var(--bg);
    transition: background-color 0.3s ease, color 0.3s ease;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    color: var(--text);
}

/* =====================
   APP LAYOUT
===================== */
#app {
    display: flex;
    flex-direction: column;
    height: 100%;
    height: 100dvh;
    width: 100vw;
    max-width: 100vw;
}

/* Global Header */
.global-header {
    height: var(--header-height);
    background: var(--surface);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    flex-shrink: 0;
    z-index: 100;
}

body.light-mode .global-header {
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.app-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
    font-size: 16px;
    color: var(--primary);
}

.app-brand i {
    font-size: 18px;
}

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

.global-actions button {
    background: transparent;
    border: none;
    color: var(--text-muted);
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.global-actions button:hover {
    background: var(--primary-muted);
    color: var(--primary);
}

.global-actions button.danger-text {
    color: var(--danger);
}

.divider {
    width: 1px;
    height: 20px;
    background: var(--text-muted);
    opacity: 0.25;
    margin: 0 4px;
}

.content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.view {
    flex: 1;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.view.active {
    display: flex;
}

/* =====================
   TAB BAR
===================== */
.tab-bar {
    display: flex;
    height: var(--tabbar-height);
    background: var(--surface);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    flex-shrink: 0;
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 1000;
}

body.light-mode .tab-bar {
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.tab-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-muted);
    gap: 4px;
    padding: 0;
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
}

.tab-item i {
    font-size: 21px;
}

.tab-item span {
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
}

.tab-item.active {
    color: var(--primary);
    background: var(--primary-muted);
}

/* =====================
   REVIEW TAB
===================== */
.header {
    padding: 6px 16px 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.stats {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 14px;
}

.stat-badges {
    display: flex;
    gap: 6px;
}

.hafal-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 700;
}

.hafal-badge.success-text {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
}

.hafal-badge.danger-text {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

.success-text {
    color: var(--success) !important;
}

.danger-text {
    color: var(--danger) !important;
}

/* =====================
   CARD
===================== */
.card-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 12px;
    perspective: 1000px;
    min-height: 0;
    gap: 16px;
}

.card {
    width: 100%;
    max-width: 420px;
    height: 100%;
    max-height: 600px;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.card.flipped {
    transform: rotateY(180deg);
}

.face {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    background: var(--surface);
    border-radius: 24px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: var(--card-shadow);
}

body.light-mode .face {
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.face.back {
    transform: rotateY(180deg);
}

.q-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 12px 0 16px;
}

.jp-text {
    font-size: 22px;
    font-weight: 700;
    line-height: 1.5;
    white-space: pre-wrap;
    text-align: center;
}

.card-hint {
    text-align: center;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 8px;
}

/* Kedua header overlay absolute, tidak memakan vertical space */
.back-header,
.front-header {
    position: absolute;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    backface-visibility: hidden;
    transform: translateZ(2px);
    z-index: 100;
}

/* NOTCH style untuk back-header (sisi belakang kartu) */
.back-header {
    top: 0;
    right: 0;
    background: #0f172a;
    /* solid dark-red */
    border-bottom-left-radius: 16px;
    border-top-right-radius: 24px;
    /* sesuai border-radius kartu */
    padding: 5px 8px;
}


.front-header {
    top: 0;
    right: 0;
    padding: 8px;
    z-index: 110;
}

.icon-btn.editing {
    background: var(--primary) !important;
    color: white !important;
    box-shadow: 0 4px 12px rgba(56, 189, 248, 0.3);
}

/* =====================
   SCROLL & CHAT
===================== */
.scroll-area {
    flex: 1;
    overflow-y: auto;
    padding-top: 4px;
    /* Bubble tidak tertutup oleh back-header absolute */
    scrollbar-width: thin;
    scrollbar-color: var(--primary-muted) transparent;
    display: flex;
    flex-direction: column;
}

.scroll-area::-webkit-scrollbar {
    width: 3px;
}

.scroll-area::-webkit-scrollbar-track {
    background: transparent;
}

.scroll-area::-webkit-scrollbar-thumb {
    background-color: var(--primary-muted);
    border-radius: 20px;
}

.chat-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 4px 0;
}

.bubble {
    max-width: 88%;
    padding: 8px 12px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    position: relative;
    word-wrap: break-word;
}

.bubble.left {
    align-self: flex-start;
    background: var(--bubble-left);
    color: var(--text);
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

body.light-mode .bubble.left {
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.bubble.right {
    align-self: flex-end;
    background: var(--bubble-right);
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

body.light-mode .bubble.right {
    color: #075e54;
}

/* Vocab highlight inside bubbles */
.vocab-mark {
    background: rgba(56, 189, 248, 0.22);
    color: var(--primary);
    border-radius: 4px;
    padding: 1px 4px;
    font-weight: 700;
    font-size: 0.92em;
    cursor: default;
}

body.light-mode .vocab-mark {
    background: rgba(2, 132, 199, 0.15);
    color: var(--primary);
}

.editing .bubble:not(.editing-focus) {
    opacity: 0.4;
    filter: blur(0.5px);
}

.bubble.editing-focus {
    opacity: 1 !important;
    filter: none !important;
    box-shadow: 0 0 15px var(--primary-muted);
    border: 1px solid var(--primary);
}

.bubble-actions {
    display: flex;
    gap: 8px;
    margin-top: 5px;
    opacity: 0.4;
    transition: opacity 0.2s;
    justify-content: flex-end;
}

.bubble:hover .bubble-actions {
    opacity: 1;
}

.bubble-actions button {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    padding: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bubble.right .bubble-actions button:hover {
    color: white;
}

body.light-mode .bubble.right .bubble-actions button:hover {
    color: var(--primary);
}

.bubble.left .bubble-actions button:hover {
    color: var(--primary);
}

.del-bubble {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 20px;
    height: 20px;
    background: var(--danger);
    color: white;
    border-radius: 50%;
    border: 2px solid var(--surface);
    font-size: 9px;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 50;
    transition: transform 0.1s;
}

.del-bubble:hover {
    transform: scale(1.2);
}

.editing .del-bubble {
    display: flex;
}

.bubble.left .del-bubble {
    right: auto;
    left: -5px;
}

/* =====================
   FOLLOW-UP + TIPS
===================== */
.follow-up-actions {
    display: flex;
    justify-content: space-between;
    margin: 12px 0;
    padding: 0 4px;
}

.mini-fab {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: none;
    background: var(--primary-muted);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    cursor: pointer;
}

.tips-section {
    margin-top: 12px;
    border-top: 1px dashed rgba(255, 255, 255, 0.1);
    padding-top: 10px;
}

body.light-mode .tips-section {
    border-top: 1px dashed rgba(0, 0, 0, 0.1);
}

.tips-section::before {
    content: "TIPS & VOCAB";
    display: block;
    font-size: 9px;
    color: var(--primary);
    font-weight: 800;
    letter-spacing: 0.08em;
    margin-bottom: 6px;
}

.tips-header {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 4px;
}

.tip-edit-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    padding: 4px;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.tip-edit-btn:hover {
    opacity: 1;
    color: var(--primary);
}

.tips-display {
    padding: 10px 12px;
    background: rgba(56, 189, 248, 0.05);
    border: 1px solid rgba(56, 189, 248, 0.12);
    border-radius: 12px;
    white-space: pre-wrap;
    line-height: 1.6;
    font-size: 13px;
}

body.light-mode .tips-display {
    background: rgba(2, 132, 199, 0.05);
    border-color: rgba(2, 132, 199, 0.12);
}

.jp-edit {
    min-height: 200px;
}

.jp-edit,
.tips-edit {
    width: 100%;
    background: rgba(255, 255, 255, 0.02);
    border: 2px solid var(--primary-muted);
    border-radius: 16px;
    padding: 20px;
    color: var(--text);
    font-size: 20px;
    font-weight: 700;
    line-height: 1.5;
    text-align: center;
    resize: none;
    outline: none;
    transition: all 0.2s ease;
    overflow-y: auto;
}

.jp-edit:focus,
.tips-edit:focus {
    border-color: var(--primary);
    background: rgba(56, 189, 248, 0.05);
    box-shadow: 0 0 15px rgba(56, 189, 248, 0.1);
}

.tips-edit {
    font-size: 15px;
    font-weight: 400;
    text-align: left;
    min-height: 120px;
}

.add-tips-btn {
    width: 100%;
    padding: 11px;
    margin-top: auto;
    margin-bottom: 5px;
    background: transparent;
    color: var(--text-muted);
    border: 1px dashed rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
    opacity: 0.5;
}

.add-tips-btn:hover {
    background: var(--primary-muted);
    color: var(--primary);
    border-color: var(--primary);
    opacity: 1;
}

/* =====================
   STATUS + CARD CONTROLS
===================== */
.status-actions-nav {
    display: flex;
    flex-direction: column;
    padding: 12px 20px 20px;
    background: var(--bg);
    flex-shrink: 0;
}

.main-actions {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    gap: 20px;
}

.secondary-actions {
    display: flex;
    gap: 8px;
    background: rgba(255, 255, 255, 0.05);
    padding: 8px 12px;
    border-radius: 30px;
}

.status-nav-btn {
    width: 64px;
    height: 64px;
    border: none;
    border-radius: 50%;
    font-weight: 800;
    color: white;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.status-nav-btn:active {
    transform: scale(0.85);
}

.status-nav-btn.belum {
    background: #ff4757;
}

.status-nav-btn.hafal {
    background: #2ed573;
}

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

.nav-extra-btn:hover {
    color: var(--primary);
    background: rgba(56, 189, 248, 0.1);
}

.nav-extra-btn:active {
    transform: scale(0.9);
}

.card-controls button:hover {
    background: var(--primary-muted);
    color: var(--primary);
}

/* =====================
   ICON BUTTONS
===================== */
.icon-btn {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
    background: var(--surface2);
    color: var(--text-muted);
}

.icon-btn.primary-btn {
    background: var(--surface2);
    color: var(--text-muted);
}

.icon-btn.primary-btn.editing {
    background: var(--primary);
    color: white;
}

.icon-btn.danger {
    background: transparent;
    color: var(--danger);
    font-size: 15px;
}


/* =====================
   JIKOSHOUKAI TAB
===================== */
.view-header {
    padding: 16px 20px 8px;
    flex-shrink: 0;
}

.view-header h1 {
    margin: 0;
    font-size: 20px;
}

.jiko-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 12px;
}

.jiko-title-block h1 {
    margin: 0;
    font-size: 26px;
    font-weight: 800;
}

.jiko-title-block p {
    margin: 4px 0 0;
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
}

.jiko-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 4px;
}

.editor-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 12px 20px 16px;
    min-height: 0;
}

#jikoshoukai-editor {
    flex: 1;
    background: transparent;
    border: none;
    border-radius: 16px;
    padding: 16px 4px;
    color: var(--text);
    font-size: 16px;
    line-height: 1.75;
    resize: none;
}

#jikoshoukai-editor[readonly] {
    background: transparent;
    cursor: default;
}

#jikoshoukai-editor:not([readonly]) {
    background: var(--surface);
    border: 1px dashed var(--primary);
    padding: 16px;
    border-radius: 16px;
}

.save-status {
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 5px;
}

/* =====================
   CARD MANAGEMENT TAB
===================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 12px;
}

.stat-item {
    background: var(--surface);
    padding: 14px 10px;
    border-radius: 14px;
    text-align: center;
    border: 1px solid rgba(0, 0, 0, 0.04);
}

.stat-value {
    display: block;
    font-size: 20px;
    font-weight: 800;
    color: var(--primary);
}

.stat-label {
    font-size: 9px;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 700;
    margin-top: 4px;
}

/* Search Bar - more distinct design */
.management-actions {
    padding: 12px 16px 8px;
    display: flex;
    align-items: center;
}

.search-box {
    background: var(--surface);
    border-radius: 16px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border: 2px solid rgba(56, 189, 248, 0.15);
    flex: 1;
    height: 48px;
    transition: all 0.2s ease;
}

.search-box:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-muted);
}

.search-icon {
    color: var(--primary);
    font-size: 14px;
    opacity: 0.7;
    flex-shrink: 0;
}

.search-box input {
    background: transparent;
    border: none;
    color: var(--text);
    flex: 1;
    font-size: 14px;
    height: 100%;
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.fab-btn {
    position: fixed;
    bottom: calc(var(--tabbar-height) + 16px);
    right: 16px;
    width: 56px;
    height: 56px;
    border-radius: 18px;
    background: var(--primary);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(56, 189, 248, 0.35);
    z-index: 1000;
    transition: all 0.2s ease;
}

.fab-btn:active {
    transform: scale(0.9);
}

.cards-management-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 20px 100px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.m-card {
    background: var(--surface);
    border-radius: 14px;
    padding: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid rgba(0, 0, 0, 0.04);
    transition: transform 0.15s;
}

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

.m-card-info h3 {
    margin: 0;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text);
}

.m-card-info p {
    margin: 4px 0 0;
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.m-card-actions {
    display: flex;
    gap: 5px;
}

.m-card-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    cursor: pointer;
}

.m-card-btn.edit {
    background: var(--primary-muted);
    color: var(--primary);
}

.m-card-btn.delete {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.bubble-edit {
    width: 100%;
    background: transparent;
    border: none;
    color: inherit;
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    min-height: initial;
    overflow: hidden;
    padding: 0;
    font-family: inherit;
}

/* =====================
   MODALS
===================== */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 20000;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(6px);
    align-items: center;
    justify-content: center;
}

.modal[style*="block"] {
    display: flex !important;
}

.modal-content {
    background: var(--surface);
    padding: 24px;
    width: 92%;
    max-width: 440px;
    border-radius: 24px;
    box-shadow: var(--card-shadow);
    animation: fadeIn 0.25s ease;
}

.modal-content.small {
    max-width: 340px;
}

.modal-header {
    margin-bottom: 18px;
}

.modal-header h3 {
    margin: 0;
    color: var(--text);
    font-size: 17px;
}

.input-group {
    margin-bottom: 14px;
}

.input-group label {
    display: block;
    font-size: 10px;
    color: var(--primary);
    font-weight: 800;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.input-group textarea {
    width: 100%;
    background: var(--bg);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 12px;
    padding: 12px;
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
    resize: none;
    min-height: 80px;
}

.modal-footer {
    display: flex;
    gap: 10px;
    margin-top: 18px;
}

.modal-footer button {
    flex: 1;
    padding: 13px;
    border-radius: 12px;
    border: none;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
}

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

.btn-secondary {
    background: var(--bg);
    color: var(--text-muted);
}

.alert-message {
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 5px;
    white-space: pre-wrap;
}

.alert-box {
    text-align: center;
}

.alert-box .modal-header h3 {
    font-size: 17px;
    margin-bottom: 8px;
}

.hidden {
    display: none !important;
}

/* =====================
   RESULT SCREEN
===================== */
.result-screen {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.4s ease;
}

.result-card {
    background: var(--surface);
    width: 100%;
    max-width: 380px;
    padding: 36px 28px;
    border-radius: 28px;
    text-align: center;
    box-shadow: var(--card-shadow);
}

.result-icon {
    font-size: 56px;
    color: #ffd700;
    margin-bottom: 16px;
}

.result-stats {
    display: flex;
    justify-content: space-around;
    margin: 24px 0;
    background: var(--bg);
    padding: 18px;
    border-radius: 18px;
}

.result-stat-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.result-stat-item .label {
    font-size: 10px;
    text-transform: uppercase;
    font-weight: 800;
    color: var(--text-muted);
}

.result-stat-item .value {
    font-size: 26px;
    font-weight: 800;
}

.result-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.result-actions .btn-primary {
    padding: 17px;
    border-radius: 18px;
    font-weight: 800;
    font-size: 14px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(56, 189, 248, 0.2);
    border: none;
}

.result-actions .btn-secondary {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 15px;
    border-radius: 18px;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
}

.result-actions .btn-primary:active,
.result-actions .btn-secondary:active {
    transform: scale(0.98);
}

.result-actions .btn-secondary:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
}

body.light-mode .result-actions .btn-secondary {
    border-color: rgba(0, 0, 0, 0.1);
}

/* =====================
   ANIMATIONS
===================== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

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

/* =====================
   RESPONSIVE - TABLET (>= 640px)
===================== */
@media (min-width: 640px) {
    .card {
        max-width: 480px;
        max-height: 500px;
    }

    .jp-text {
        font-size: 26px;
    }

    .status-actions-nav {
        padding: 12px 60px 24px;
        gap: 16px;
    }

    .status-nav-btn {
        font-size: 16px;
        padding: 18px;
    }

    .card-controls button {
        width: 40px;
        height: 40px;
        font-size: 14px;
    }

    .global-header {
        padding: 0 32px;
    }

    .view-header {
        padding: 20px 40px 8px;
    }

    .management-actions {
        padding: 10px 40px;
    }

    .cards-management-list {
        padding: 0 40px 24px;
    }

    .editor-container {
        padding: 14px 40px 20px;
    }
}

/* =====================
   RESPONSIVE - DESKTOP (>= 1024px)
===================== */
@media (min-width: 1024px) {

    /* Batasi lebar app dan pusatkan */
    #app {
        max-width: 860px;
        margin: 0 auto;
        border-left: 1px solid rgba(255, 255, 255, 0.05);
        border-right: 1px solid rgba(255, 255, 255, 0.05);
    }

    body.light-mode #app {
        border-color: rgba(0, 0, 0, 0.07);
    }

    .card {
        max-width: 540px;
        max-height: 490px;
    }

    .card-container {
        padding: 16px 80px;
    }

    .status-actions-nav {
        padding: 12px 80px 26px;
    }

    .tab-bar {
        height: 72px;
    }

    .tab-item i {
        font-size: 22px;
    }

    .view-header {
        padding: 24px 60px 10px;
    }

    .management-actions {
        padding: 10px 60px;
    }

    .cards-management-list {
        padding: 0 60px 28px;
    }

    .editor-container {
        padding: 16px 60px 24px;
    }

    .global-header {
        padding: 0 40px;
    }
}

/* =====================
   FILTER TABS - CARD MANAGEMENT
===================== */
.m-filter-tabs {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 4px 16px 14px;
    flex-shrink: 0;
}

.m-filter-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 0;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: var(--surface2);
    color: var(--text-muted);
    font-size: 15px;
    /* Slightly larger icon */
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 0;
}

.m-filter-tab:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.m-filter-tab.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 4px 10px rgba(56, 189, 248, 0.2);
}

.tab-count {
    font-size: 11px;
    background: rgba(0, 0, 0, 0.25);
    padding: 1px 7px;
    border-radius: 8px;
    margin-left: 2px;
    font-weight: 800;
    opacity: 0.7;
}

.m-filter-tab.active .tab-count {
    background: rgba(255, 255, 255, 0.2);
    opacity: 1;
}

.m-filter-tab[data-filter="starred"].active {
    background: #f59e0b;
    border-color: #f59e0b;
}

.m-filter-tab[data-filter="arsip"].active {
    background: var(--text-muted);
    border-color: var(--text-muted);
}

/* =====================
   CARD LIST - ARCHIVE & STAR
===================== */
.m-card {
    cursor: pointer;
    transition: background 0.15s, opacity 0.2s;
}

.m-card:hover {
    background: var(--surface2);
}

.m-card.archived {
    opacity: 0.55;
}

.m-card.archived .m-card-info h3 {
    text-decoration: line-through;
    color: var(--text-muted);
}

.m-card-meta {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-bottom: 4px;
}

.m-star-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
}

.m-archived-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(148, 163, 184, 0.15);
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
}

.m-card-btn.star {
    background: transparent;
    color: var(--text-muted);
    border: none;
}

.m-card-btn.star:hover,
.m-card-btn.star.starred-active {
    color: #f59e0b;
    background: rgba(245, 158, 11, 0.12);
}

.m-card-btn.archive {
    background: transparent;
    color: var(--text-muted);
    border: none;
}

.m-card-btn.archive:hover {
    color: var(--primary);
    background: var(--primary-muted);
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    color: var(--text-muted);
    gap: 12px;
    opacity: 0.6;
}

.empty-state i {
    font-size: 40px;
}

.empty-state p {
    margin: 0;
    font-size: 14px;
}

/* =====================
   STAR BUTTON - FRONT CARD
===================== */
.star-btn-front {
    background: transparent;
    color: var(--text-muted);
    border: none;
    font-size: 16px;
    transition: color 0.2s, transform 0.15s;
}

.star-btn-front:hover {
    color: #f59e0b;
    transform: scale(1.2);
}

.star-btn-front.starred {
    color: #f59e0b;
}

.star-btn-front.starred i {
    filter: drop-shadow(0 0 6px rgba(245, 158, 11, 0.5));
}

/* =====================
   TOAST NOTIFICATION
===================== */
#toast-container {
    position: fixed;
    bottom: calc(var(--tabbar-height) + 16px);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 9999;
    pointer-events: none;
    align-items: center;
}

.toast {
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    color: white;
    background: #334155;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transform: translateY(10px) scale(0.95);
    transition: opacity 0.25s ease, transform 0.25s ease;
    white-space: nowrap;
}

.toast.show {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.toast-success {
    background: #16a34a;
}

.toast-info {
    background: #0284c7;
}

.toast-warning {
    background: #d97706;
}

.toast-danger {
    background: #dc2626;
}

/* =====================
   FRONT CARD HINT
===================== */
.front-hint-area {
    margin-top: auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-bottom: 24px;
}

.hint-add-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px dashed rgba(255, 255, 255, 0.15);
    color: var(--text-muted);
    font-size: 12px;
    padding: 6px 16px;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.hint-add-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text);
    border-color: rgba(255, 255, 255, 0.3);
}

body.light-mode .hint-add-btn {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.1);
}

body.light-mode .hint-add-btn:hover {
    background: rgba(0, 0, 0, 0.06);
    border-color: rgba(0, 0, 0, 0.2);
}

.hint-toggle-btn {
    background: transparent;
    border: none;
    color: #f59e0b;
    /* Yellowish for hint */
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    padding: 6px 12px;
    opacity: 0.8;
    transition: opacity 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.hint-toggle-btn:hover {
    opacity: 1;
}

.hint-text {
    margin-top: 8px;
    font-size: 14px;
    color: var(--text-muted);
    background: rgba(245, 158, 11, 0.05);
    border: 1px solid rgba(245, 158, 11, 0.2);
    padding: 10px 14px;
    border-radius: 12px;
    width: 90%;
    text-align: center;
    position: relative;
    animation: fadeIn 0.3s ease;
}

.hint-edit-small {
    position: absolute;
    top: -8px;
    right: -8px;
    background: var(--surface2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.hint-editor-wrap {
    width: 95%;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.hint-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--primary-muted);
    border-radius: 12px;
    padding: 12px;
    color: var(--text);
    font-size: 14px;
    min-height: 80px;
    resize: none;
    outline: none;
    text-align: center;
}

body.light-mode .hint-input {
    background: rgba(0, 0, 0, 0.02);
}

.hint-input:focus {
    border-color: var(--primary);
}

.hint-editor-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.hint-save-btn,
.hint-cancel-btn {
    padding: 6px 16px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    border: none;
}

.hint-save-btn {
    background: var(--primary);
    color: white;
}

.hint-cancel-btn {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text);
}

body.light-mode .hint-cancel-btn {
    background: rgba(0, 0, 0, 0.1);
}

@media (min-width: 600px) {
    .m-filter-tabs {
        padding: 6px 60px 10px;
    }
}