/* ==========================================================================
   Pomodoro — cream, dark cocoa #3E2727 & matcha green #BDD373
   Design tokens are shared with hub.css
   ========================================================================== */
:root {
    --bg: #FBF5E9;               /* cream */
    --surface: #FFFDF9;
    --surface-2: #F5EDDE;
    --track: #ECE3D2;
    --border: rgba(62, 39, 39, 0.13);
    --border-strong: rgba(62, 39, 39, 0.24);
    --text: #3E2727;             /* dark cocoa */
    --text-2: #6A5352;
    --muted: #7E6A64;
    --primary: #BDD373;          /* matcha green fill */
    --primary-hover: #AFC862;
    --primary-soft: #EDF3D8;
    --primary-ink: #566A1C;      /* readable green for text & icons */
    --primary-strong: #86A136;   /* progress bars */
    --on-primary: #3E2727;       /* text on green buttons */
    --ok: #4F7A1E;
    --ok-soft: #E9F1D6;
    --warn: #B4471F;
    --warn-soft: #FBE9DF;
    --radius: 20px;
    --radius-sm: 12px;
    --shadow: 0 1px 2px rgba(62, 39, 39, 0.05), 0 10px 30px rgba(62, 39, 39, 0.07);
    --shadow-lg: 0 2px 4px rgba(62, 39, 39, 0.06), 0 20px 50px rgba(62, 39, 39, 0.15);
    --font: 'Plus Jakarta Sans', 'Noto Sans Thai', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

/* breaks: buttons turn dark cocoa so you can tell at a glance */
body[data-mode="shortBreak"], body[data-mode="longBreak"] {
    --primary: #3E2727;
    --primary-hover: #2B1A1A;
    --primary-soft: #EFE4DF;
    --primary-ink: #3E2727;
    --primary-strong: #3E2727;
    --on-primary: #FBF5E9;
}

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

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    text-align: center;
    overflow: hidden;
}

.ic { display: inline-block; vertical-align: middle; flex-shrink: 0; }

/* ---------- buttons ---------- */
button { font-family: var(--font); cursor: pointer; }
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    border-radius: var(--radius-sm);
    padding: 10px 18px;
    font-size: 15px;
    font-weight: 600;
    line-height: 1;
    transition: background-color .15s ease, transform .1s ease, box-shadow .15s ease, color .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .seg button:focus-visible, input:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary-strong) 45%, transparent); outline-offset: 2px; }
.btn-primary { background: var(--primary); color: var(--on-primary); box-shadow: 0 4px 14px color-mix(in srgb, var(--primary-strong) 30%, transparent); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-soft { background: var(--primary-soft); color: var(--primary-ink); }
.btn-soft:hover { background: color-mix(in srgb, var(--primary-soft) 70%, var(--primary) 12%); }
.btn-ghost { background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow); }
.btn-ghost:hover { background: #fff; border-color: var(--border-strong); }
.btn-link { background: none; border: none; color: var(--muted); font-size: 13px; font-weight: 600; padding: 4px 6px; border-radius: 8px; }
.btn-link:hover:not(:disabled) { color: var(--primary-ink); background: var(--primary-soft); }
.btn-link:disabled { opacity: .45; cursor: default; }

/* ---------- segmented control ---------- */
.seg {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    background: var(--surface-2);
    border-radius: 14px;
}
.seg button {
    border: none;
    background: transparent;
    color: var(--text-2);
    font-size: 14px;
    font-weight: 600;
    padding: 8px 14px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background-color .15s ease, color .15s ease, box-shadow .15s ease;
}
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--surface); color: var(--primary-ink); box-shadow: 0 1px 3px rgba(60, 40, 20, .12); }

/* ---------- cards ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

/* ---------- login (top right) ---------- */
.LogIn { position: absolute; top: 20px; right: 20px; z-index: 30; display: flex; gap: 8px; }
.LogIn .btn { padding: 9px 14px; font-size: 14px; }

/* ---------- background video ---------- */
#background-video-container { position: fixed; inset: 0; z-index: -1; }
#background-video { width: 100%; height: 100%; border: 0; }

/* ---------- layout & draggable cards ---------- */
.container { display: flex; flex-direction: column; align-items: center; gap: 20px; }

#draggable-container1 {
    position: absolute;
    top: 76px;
    width: 380px;
    padding: 22px 24px 24px;
    cursor: move;
}
#draggable-container {
    position: absolute;
    top: 404px;
    width: 340px;
    padding: 20px;
    cursor: move;
    text-align: left;
}

/* ---------- timer ---------- */
.timer-card .mode-buttons { display: flex; width: 100%; margin: 6px 0 0; }
.timer-card .mode-buttons button { flex: 1; justify-content: center; padding: 9px 6px; font-size: 13.5px; }
.time-display {
    font-size: 88px;
    font-weight: 800;
    letter-spacing: -0.04em;
    line-height: 1;
    margin: 22px 0 20px;
    font-variant-numeric: tabular-nums;
    color: var(--text);
}
.buttons { display: flex; gap: 10px; justify-content: center; }
.buttons .btn { min-width: 128px; padding: 12px 18px; }
#startPauseBtn.is-running { background: var(--text); color: #FBF5E9; box-shadow: 0 4px 14px rgba(62, 54, 49, .25); }
#startPauseBtn.is-running:hover { background: #2a2420; }

/* ---------- to-do ---------- */
.todo-head { display: flex; align-items: center; gap: 8px; color: var(--primary-ink); margin-bottom: 14px; }
.todo-head h1 { font-size: 18px; font-weight: 700; margin: 0; color: var(--text); letter-spacing: -0.01em; }
.task-input { display: flex; gap: 8px; }
#new-task {
    flex: 1;
    min-width: 0;
    border: 1px solid var(--border-strong);
    background: #fff;
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font: inherit;
    font-size: 14px;
    color: var(--text);
    outline: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}
#new-task:focus { border-color: var(--primary-strong); box-shadow: 0 0 0 3px var(--primary-soft); }
#add-task-btn { padding: 10px 14px; font-size: 14px; }

#task-list {
    list-style: none;
    margin: 12px 0 0;
    padding: 0 2px;
    max-height: clamp(110px, calc(100vh - 690px), 34vh);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
}
#task-list li {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 6px;
    border-radius: 10px;
    cursor: default;
    transition: background-color .15s ease;
}
#task-list li + li { margin-top: 2px; }
#task-list li:hover { background: var(--surface-2); }
#task-list .task-content { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
#task-list .task-text { flex: 1; min-width: 0; font-size: 14.5px; font-weight: 500; overflow-wrap: anywhere; }
#task-list li.checked .task-text { text-decoration: line-through; color: var(--muted); }
#task-list input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    margin: 0;
    border: 2px solid var(--border-strong);
    border-radius: 7px;
    background: #fff;
    cursor: pointer;
    display: grid;
    place-content: center;
    transition: background-color .15s ease, border-color .15s ease;
}
#task-list input[type="checkbox"]::after {
    content: "";
    width: 10px;
    height: 6px;
    border-left: 2px solid var(--on-primary);
    border-bottom: 2px solid var(--on-primary);
    transform: rotate(-45deg) translate(1px, -1px);
    opacity: 0;
}
#task-list input[type="checkbox"]:checked { background: var(--primary); border-color: var(--primary-strong); }
#task-list input[type="checkbox"]:checked::after { opacity: 1; }

/* 6-dot grip drawn with CSS */
#task-list .drag-handle {
    flex-shrink: 0;
    width: 10px;
    height: 18px;
    background-image: radial-gradient(circle, #C9BBAA 1.3px, transparent 1.5px);
    background-size: 5px 6px;
    background-position: center;
    cursor: grab;
    touch-action: none;
    opacity: .7;
}
#task-list li:hover .drag-handle { opacity: 1; }
#task-list li.dragging { background: var(--primary-soft); box-shadow: var(--shadow); }
#task-list li.dragging .drag-handle { cursor: grabbing; }

#task-list .icon-group { display: flex; gap: 2px; flex-shrink: 0; opacity: 0; transition: opacity .15s ease; }
#task-list li:hover .icon-group, #task-list .icon-group:focus-within { opacity: 1; }
@media (hover: none) { #task-list .icon-group { opacity: 1; } }
.edit-btn, .delete-btn {
    display: inline-grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 8px;
    background: none;
    color: var(--muted);
}
.edit-btn:hover { background: var(--surface); color: var(--text); }
.delete-btn:hover { background: var(--warn-soft); color: var(--warn); }

.task-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}
.task-footer[hidden] { display: none; }
#task-count { font-size: 13px; font-weight: 600; color: var(--muted); }

/* ---------- YouTube background bar ---------- */
.youtube-input {
    position: absolute;
    bottom: 40px;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 8px;
    width: min(520px, calc(100vw - 32px));
    padding: 6px 6px 6px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    box-shadow: var(--shadow);
}
.youtube-input .yt-icon { color: #E0464B; display: inline-flex; }
.youtube-input input {
    flex: 1;
    min-width: 0;
    border: none;
    outline: none;
    background: transparent;
    font: inherit;
    font-size: 14px;
    color: var(--text);
    padding: 8px 0;
}
.youtube-input .btn { border-radius: 999px; padding: 9px 18px; font-size: 14px; }

/* ---------- edge tabs (left: stats, right: hub) ---------- */
.edge-tab {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    z-index: 40;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 14px 9px;
    background: var(--surface);
    color: var(--text-2);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    font-size: 12.5px;
    font-weight: 700;
    letter-spacing: .02em;
    transition: color .15s ease, padding .15s ease, background-color .15s ease;
}
.edge-tab span { writing-mode: vertical-rl; transform: rotate(180deg); }
.edge-tab:hover { color: var(--primary-ink); background: #fff; }
.edge-left { left: 0; border-left: none; border-radius: 0 14px 14px 0; }
.edge-left:hover { padding-left: 13px; }
.edge-right { right: 0; border-right: none; border-radius: 14px 0 0 14px; }
.edge-right span { transform: none; }
.edge-right:hover { padding-right: 13px; }

/* ---------- study time card (left) ---------- */
#study-dashboard {
    position: fixed;
    left: 56px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 35;
    width: 260px;
    padding: 20px;
    display: none;
    text-align: left;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
}
.sc-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 16px; }
.sc-head h2 { font-size: 17px; margin: 0; font-weight: 700; }
.streak-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--primary-soft);
    color: var(--primary-ink);
    font-size: 12.5px;
    font-weight: 700;
    padding: 5px 10px;
    border-radius: 999px;
}
.goal-row { display: flex; justify-content: space-between; font-size: 13.5px; color: var(--text-2); }
.goal-row b { color: var(--text); }
.progress-outer { height: 8px; background: var(--track); border-radius: 99px; overflow: hidden; margin: 8px 0 18px; }
.progress-inner { height: 100%; background: var(--primary-strong); width: 0%; border-radius: 99px; transition: width .3s ease; }
.totals { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.total-block { background: var(--surface-2); border-radius: 14px; padding: 12px; }
.label { font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 2px; }
.value { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.value .unit-hour, .value .unit-min { font-size: 13px; font-weight: 600; color: var(--muted); margin: 0 4px 0 1px; }

/* ---------- small screens ---------- */
@media (max-width: 600px) {
    body { overflow: auto; }
    #draggable-container1 { width: calc(100vw - 32px); top: 72px; padding: 18px; }
    #draggable-container { width: calc(100vw - 32px); }
    .time-display { font-size: 72px; }
    .buttons .btn { min-width: 0; flex: 1; }
    .LogIn { top: 14px; right: 14px; }
    .LogIn .btn { padding: 8px 10px; font-size: 13px; }
    #study-dashboard { left: 16px; right: 16px; width: auto; }
    .youtube-input { bottom: 16px; }
}

/* ---------- YouTube player controls (inside the bottom bar) ---------- */
#background-video, #background-video iframe { width: 100%; height: 100%; border: 0; display: block; }
.yt-ctrls { display: none; flex: 1; min-width: 0; align-items: center; gap: 4px; }
.youtube-input.has-video .yt-ctrls { display: flex; }
.youtube-input.has-video > input,
.youtube-input.has-video > .btn { display: none; }
.youtube-input .yt-cancel { display: none; }
.youtube-input.editing .yt-cancel { display: inline-grid; }
.yt-btn {
    display: inline-grid; place-items: center; flex-shrink: 0;
    width: 34px; height: 34px; padding: 0; border: none; border-radius: 50%;
    background: transparent; color: var(--text-2); cursor: pointer;
    transition: background-color .15s ease, color .15s ease;
}
.yt-btn:hover { background: var(--surface-2); color: var(--text); }
.yt-btn.yt-play { width: 38px; height: 38px; background: var(--primary); color: var(--on-primary); }
.yt-btn.yt-play:hover { background: var(--primary-hover); color: var(--on-primary); }
.yt-time { flex-shrink: 0; font-size: 12px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 34px; text-align: center; }
.yt-status { position: absolute; left: 50%; top: -22px; transform: translateX(-50%); font-size: 11.5px; font-weight: 600; color: var(--text-2); white-space: nowrap; pointer-events: none; }
#yt-seek {
    flex: 1; min-width: 60px; height: 6px; margin: 0 4px;
    -webkit-appearance: none; appearance: none; border-radius: 99px; cursor: pointer;
    background: linear-gradient(90deg, var(--primary-strong) var(--p, 0%), var(--track) var(--p, 0%));
}
#yt-seek::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 2px solid var(--primary-strong); box-shadow: 0 1px 4px rgba(62, 39, 39, .25); }
#yt-seek::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 2px solid var(--primary-strong); }
#yt-seek:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary-strong) 40%, transparent); outline-offset: 3px; }
.youtube-input.has-video { padding: 6px 8px; }
.youtube-input.has-video .yt-icon { display: none; }
@media (max-width: 600px) {
    .yt-ctrls [data-yt="back"], .yt-ctrls [data-yt="fwd"] { display: none; }
    .yt-time { min-width: 0; font-size: 11px; }
}
