/* GreekTool styles */

:root {
    --bg: #f6f4ef;
    --surface: #ffffff;
    --surface-2: #f0ede6;
    --text: #1f2328;
    --muted: #646b73;
    --border: #ddd8cc;
    --accent: #274c77;
    --accent-text: #ffffff;
    --accent-soft: #e3ebf5;
    --danger: #b3261e;
    --again: #c0392b;
    --hard: #c77c0e;
    --good: #2e7d32;
    --easy: #1f6fb2;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 4px 16px rgba(0, 0, 0, .05);
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-greek: "Gentium Plus", "Gentium Book Plus", "GFS Didot", "Noto Serif", "Palatino Linotype", "Times New Roman", serif;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #16181c;
        --surface: #1f2228;
        --surface-2: #272b32;
        --text: #e6e6e6;
        --muted: #9aa1a9;
        --border: #343943;
        --accent: #7aa7d9;
        --accent-text: #0e1620;
        --accent-soft: #233244;
        --danger: #ff8a80;
        --shadow: none;
    }
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.5;
}

a { color: var(--accent); }

.greek { font-family: var(--font-greek); }

.loading, .empty {
    color: var(--muted);
    text-align: center;
    padding: 2rem 1rem;
}

/* Layout */

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar-inner, main {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 16px;
}

.topbar-inner {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-height: 56px;
    flex-wrap: wrap;
}

.brand {
    font-weight: 700;
    font-size: 1.15rem;
    text-decoration: none;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: .5rem;
}

.brand-logo {
    display: inline-grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 7px;
    background: var(--accent);
    color: var(--accent-text);
    font-family: var(--font-greek);
    font-size: 1.2rem;
}

nav.tabs {
    display: flex;
    gap: .25rem;
    flex: 1;
    overflow-x: auto;
}

nav.tabs a {
    text-decoration: none;
    color: var(--muted);
    padding: .4rem .75rem;
    border-radius: 8px;
    white-space: nowrap;
}

nav.tabs a:hover { background: var(--surface-2); color: var(--text); }
nav.tabs a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.usermenu {
    display: flex;
    align-items: center;
    gap: .5rem;
    color: var(--muted);
    font-size: .9rem;
}

main { padding-top: 1.5rem; padding-bottom: 3rem; }

h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.page-head h1 { margin: 0; }

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    margin-bottom: 1rem;
}

/* Forms */

label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .25rem; }
label .hint { font-weight: 400; color: var(--muted); }

input[type=text], input[type=password], input[type=number], input[type=search], select, textarea {
    width: 100%;
    font: inherit;
    color: inherit;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .5rem .65rem;
}

textarea { min-height: 6rem; resize: vertical; }

input:focus, select:focus, textarea:focus, button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.field { margin-bottom: .9rem; }

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 1rem;
}

@media (max-width: 640px) {
    .grid-2 { grid-template-columns: 1fr; }
}

.check {
    display: flex;
    align-items: center;
    gap: .4rem;
    font-weight: 400;
    margin: 0;
    cursor: pointer;
}

.row {
    display: flex;
    gap: .5rem;
    align-items: center;
    flex-wrap: wrap;
}

.form-actions {
    display: flex;
    gap: .5rem;
    justify-content: flex-end;
    margin-top: .5rem;
}

.error {
    color: var(--danger);
    font-size: .9rem;
    margin: .5rem 0;
}

.notice {
    background: var(--accent-soft);
    border-radius: 8px;
    padding: .75rem 1rem;
    margin-bottom: 1rem;
}

/* Buttons */

button, .btn {
    font: inherit;
    font-size: .95rem;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    border-radius: 8px;
    padding: .45rem .9rem;
    cursor: pointer;
    white-space: nowrap;
}

button:hover { background: var(--surface-2); }
button:disabled { opacity: .5; cursor: default; }

button.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-text);
    font-weight: 600;
}

button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--danger); }
button.small { font-size: .8rem; padding: .2rem .55rem; }
button.link { border: none; background: none; color: var(--accent); padding: .2rem .4rem; }

/* Tags */

.tags { display: flex; gap: .3rem; flex-wrap: wrap; }

.tag {
    font-size: .75rem;
    background: var(--surface-2);
    color: var(--muted);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: .05rem .55rem;
}

button.tag { cursor: pointer; font-size: .85rem; padding: .2rem .7rem; }
button.tag.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

/* Entry lists */

.toolbar {
    display: flex;
    gap: .5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.toolbar input[type=search] { flex: 1 1 220px; width: auto; }
.toolbar select { flex: 0 1 200px; width: auto; }

.entries { display: grid; gap: .6rem; }

.entry {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .85rem 1rem;
}

.entry-head {
    display: flex;
    align-items: baseline;
    gap: .75rem;
    flex-wrap: wrap;
}

.entry-title { font-size: 1.2rem; font-weight: 600; }
.entry-title.greek { font-size: 1.35rem; font-weight: 400; }
.entry-sub { color: var(--text); }
.entry-meta { color: var(--muted); font-size: .85rem; }
.entry-body { white-space: pre-wrap; margin-top: .4rem; overflow-wrap: anywhere; }
.entry-extra { margin-top: .35rem; font-size: .92rem; white-space: pre-wrap; }
.entry-extra b { color: var(--muted); font-weight: 600; }

.entry-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    margin-top: .5rem;
    flex-wrap: wrap;
}

.entry-actions { display: flex; gap: .25rem; }
.count { color: var(--muted); font-size: .9rem; margin-bottom: .5rem; }

/* Study */

.stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: .75rem;
    margin-bottom: 1rem;
}

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .75rem 1rem;
}

.stat-value { font-size: 1.8rem; font-weight: 700; line-height: 1.1; }
.stat-label { color: var(--muted); font-size: .85rem; }

.study-options {
    display: grid;
    gap: 1rem;
}

.option-group > .label {
    font-weight: 600;
    font-size: .9rem;
    margin-bottom: .35rem;
}

.flashcard {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow);
    min-height: 300px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    text-align: center;
}

.flashcard-kind {
    color: var(--muted);
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .06em;
}

.flashcard-front {
    font-size: 2rem;
    margin: 1.25rem 0;
    overflow-wrap: anywhere;
}

.flashcard-front.greek { font-size: 2.6rem; }

.flashcard-back {
    border-top: 1px dashed var(--border);
    padding-top: 1rem;
    overflow-wrap: anywhere;
}

.flashcard-answer { font-size: 1.6rem; margin-bottom: .5rem; }
.flashcard-answer.greek { font-size: 2.2rem; }
.flashcard-back .entry-body { text-align: left; }
.flashcard-back .entry-extra { text-align: left; }

.flashcard .spacer { flex: 1; }

.study-progress {
    display: flex;
    justify-content: space-between;
    color: var(--muted);
    font-size: .9rem;
    margin-bottom: .5rem;
}

.grades {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: .5rem;
    margin-top: 1rem;
}

.grades button {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: .6rem .3rem;
    font-weight: 600;
    color: #fff;
    border: none;
}

.grades button small { font-weight: 400; opacity: .9; }
.grades .again { background: var(--again); }
.grades .hard { background: var(--hard); }
.grades .good { background: var(--good); }
.grades .easy { background: var(--easy); }
.grades button:hover { filter: brightness(1.1); background-image: none; }

.show-answer { width: 100%; margin-top: 1rem; padding: .8rem; }

.kbd-hint { color: var(--muted); font-size: .8rem; text-align: center; margin-top: .75rem; }

/* Tables */

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .55rem .5rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: .85rem; color: var(--muted); font-weight: 600; }
td select { width: auto; padding: .25rem .4rem; }

.badge {
    font-size: .75rem;
    border-radius: 999px;
    padding: .05rem .5rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
}

.badge.off { color: var(--danger); }

/* Login */

.login-wrap {
    max-width: 380px;
    margin: 10vh auto 0;
    padding: 0 16px;
}

.login-wrap .brand { justify-content: center; font-size: 1.5rem; margin-bottom: 1.25rem; }
.login-wrap .brand-logo { width: 40px; height: 40px; font-size: 1.6rem; }
.login-wrap button.primary { width: 100%; padding: .65rem; }

/* Dialog */

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 5vh 16px;
    z-index: 100;
    overflow-y: auto;
}

.dialog {
    background: var(--surface);
    border-radius: 14px;
    width: 100%;
    max-width: 640px;
    padding: 1.25rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, .25);
}

/* Toast */

.toast {
    position: fixed;
    bottom: 1.25rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text);
    color: var(--bg);
    padding: .6rem 1rem;
    border-radius: 8px;
    z-index: 200;
    font-size: .9rem;
    max-width: calc(100% - 32px);
}

/* Greek keyboard */

.gk {
    display: flex;
    flex-wrap: wrap;
    gap: .2rem;
    margin-top: .35rem;
}

.gk button {
    font-family: var(--font-greek);
    font-size: 1.05rem;
    padding: .1rem .45rem;
    min-width: 2rem;
}

.gk-toggle { font-size: .8rem; }

/* Form tables (declensions, conjugations, ...) */

.forms-details { margin-top: .5rem; }
.forms-details summary { cursor: pointer; color: var(--accent); font-size: .92rem; }
.forms-details[open] summary { margin-bottom: .25rem; }

.forms-table { margin: .5rem 0 .75rem; }
.forms-title { font-weight: 600; font-size: .92rem; margin-bottom: .25rem; }

table.forms {
    width: auto;
    min-width: 50%;
    border: 1px solid var(--border);
    border-radius: 8px;
    border-collapse: separate;
    border-spacing: 0;
    overflow: hidden;
}

table.forms th, table.forms td {
    padding: .3rem .7rem;
    border-bottom: 1px solid var(--border);
    font-size: .95rem;
}

table.forms tr:last-child th, table.forms tr:last-child td { border-bottom: none; }
table.forms tbody th { color: var(--muted); font-weight: 600; font-size: .85rem; white-space: nowrap; background: var(--surface-2); }
table.forms thead th { background: var(--surface-2); }
table.forms td.greek { font-size: 1.1rem; }
table.forms td.hit { background: var(--accent-soft); color: var(--accent); font-weight: 700; }

.flashcard-back table.forms { margin: 0 auto; text-align: left; }
.flashcard-back .forms-title { text-align: center; }
.flashcard-back .forms-details { text-align: left; }

.form-headword { font-size: 2.2rem; }
.form-question {
    font-size: 1.1rem;
    margin-top: .75rem;
    color: var(--accent);
    font-weight: 600;
}

/* Table editor */

/* minmax(0, 1fr) lets wide tables scroll inside the editor
   instead of stretching the dialog. */
.tables-editor { display: grid; grid-template-columns: minmax(0, 1fr); gap: .75rem; }
.dialog:has(.tables-editor) { max-width: 960px; }

.table-editor {
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .6rem;
    background: var(--surface-2);
}

.table-editor > .row { margin: .25rem 0; }
.table-editor .table-title { flex: 1; width: auto; font-weight: 600; }

table.forms.edit { width: 100%; background: var(--surface); }
table.forms.edit th, table.forms.edit td { padding: .2rem; background: var(--surface); }
table.forms.edit input { padding: .25rem .4rem; min-width: 6.5rem; border-radius: 6px; }
table.forms.edit tbody th input { font-weight: 600; min-width: 7rem; }
table.forms.edit td:last-child { width: 1%; }

.cell-edit { display: flex; gap: .2rem; align-items: center; }
button.icon { padding: .1rem .45rem; line-height: 1.2; }

/* Keep the row labels visible while scrolling wide tables sideways */
table.forms.edit tbody th,
table.forms.edit thead th:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
}

/* Languages */

.lang-switch { display: inline-flex; gap: 0; }
.lang-switch button { border-radius: 0; margin-left: -1px; font-weight: 600; }
.lang-switch button:first-child { border-radius: 8px 0 0 8px; margin-left: 0; }
.lang-switch button:last-child { border-radius: 0 8px 8px 0; }
.lang-switch button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

.login-lang { display: flex; justify-content: flex-end; margin-bottom: .5rem; }

.lang-filter { display: flex; gap: .3rem; flex-wrap: wrap; }
.toolbar .lang-filter { margin-top: -.5rem; }

.tag.lang { font-weight: 700; letter-spacing: .03em; }
