/* =========================================================================
   File Manager — interface styles
   ========================================================================= */

:root {
    --page:         #eceff4;
    --surface:      #ffffff;
    --surface-soft: #f6f7f9;
    --surface-sunk: #f1f3f7;
    --line:         #eceef3;
    --line-strong:  #dfe3ea;

    --text:   #1e2430;
    --text-2: #626b7a;
    --text-3: #99a1ae;

    /* Taken from the application icon: --accent is the saturated sheet at the
       back of it, --accent-dark a quarter darker so hover states move by the
       same step the old green pair moved by. Keep these in step with the Fm
       class in flutter-client/lib/theme.dart, which is the same palette for
       the desktop app. */
    --accent:      #b04ad6;
    --accent-dark: #9a34c2;
    --accent-soft: #f7eefc;
    /* Dark enough to carry white text: 4.63:1, where the old #e5484d was 3.91
       and fell short of the 4.5 minimum. Used for buttons, error toasts and
       the recycle-bin badge alike. */
    --danger:        #d63a40;
    --danger-strong: #b42d31;
    --danger-soft:   #fdecec;

    --radius-lg: 16px;
    --radius:    12px;
    --radius-sm: 8px;

    --shadow-sm: 0 1px 2px rgba(20, 28, 45, .05);
    --shadow:    0 4px 16px rgba(20, 28, 45, .08);
    --shadow-lg: 0 18px 48px rgba(20, 28, 45, .16);

    --rail:    64px;
    --sidebar: 218px;
    --details: 272px;
    --topbar:  64px;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
    height: 100%;
    margin: 0;
}

/* Inter carries no Tamil glyphs, so the Tamil faces sit behind it in the stack
   and the browser reaches past for anything in the Tamil block. Without them a
   file called ஆவணம் falls back to whatever the system picks, which on Windows
   is usually a mismatched serif. */
body {
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial,
                 "Noto Sans Tamil", "Nirmala UI", "Latha", "Tamil Sangam MN", sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--page);
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
.muted { color: var(--text-3); font-weight: 400; }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* =========================================================================
   Shell
   ========================================================================= */

.app {
    display: grid;
    grid-template-columns: var(--rail) var(--sidebar) minmax(0, 1fr) var(--details);
    grid-template-rows: var(--topbar) minmax(0, 1fr);
    grid-template-areas:
        "topbar topbar  topbar topbar"
        "rail   sidebar main   details";
    height: 100vh;
    height: 100dvh;
    background: var(--surface);
}

/* ------------------------------------------------------------- top bar -- */

.topbar {
    grid-area: topbar;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.topbar__brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.topbar__logo {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 11px;
    background: var(--accent-soft);
    flex: none;
}

.topbar__title {
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.01em;
    white-space: nowrap;
}

.topbar__right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.topbar__usage {
    font-size: 12.5px;
    color: var(--text-2);
    white-space: nowrap;
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--surface-soft);
}

.chip {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 5px 10px 5px 5px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    cursor: pointer;
    transition: background .15s, border-color .15s;
}
.chip:hover { background: var(--surface-soft); border-color: var(--line-strong); }

.chip__name {
    font-size: 13px;
    font-weight: 500;
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.avatar {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    flex: none;
}

/* dropdown */
.menu { position: relative; }

.menu__panel {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    min-width: 220px;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 40;
}
.menu__panel[hidden] { display: none; }

.menu__head {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 6px;
}
.menu__head strong { font-size: 13.5px; }
.menu__head span {
    font-size: 12px;
    color: var(--text-3);
    overflow: hidden;
    text-overflow: ellipsis;
}

.menu__item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 12px;
    border: 0;
    border-radius: var(--radius-sm);
    background: none;
    font-size: 13.5px;
    text-align: left;
    cursor: pointer;
}
.menu__item:hover { background: var(--surface-soft); }

/* ---------------------------------------------------------------- rail -- */

.rail {
    grid-area: rail;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 16px 0;
    background: var(--surface);
    border-right: 1px solid var(--line);
    overflow-y: auto;
}

.rail__item {
    position: relative;
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 11px;
    color: var(--text-3);
    transition: background .15s, color .15s;
}
.rail__item:hover { background: var(--surface-soft); color: var(--text-2); }

.rail__item.is-active {
    background: var(--accent-soft);
    color: var(--accent-dark);
}
.rail__item.is-active::before {
    content: "";
    position: absolute;
    left: -13px;
    width: 3px;
    height: 22px;
    border-radius: 0 3px 3px 0;
    background: var(--accent);
}

/* ------------------------------------------------------------- sidebar -- */

.sidebar {
    grid-area: sidebar;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--surface);
    border-right: 1px solid var(--line);
}

.sidebar__scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 18px 12px 8px;
}
.sidebar__actions + .sidebar__scroll { padding-top: 14px; }

.sidebar__label {
    margin: 0 0 10px 10px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: var(--text-3);
}

.sidebar__hint {
    margin: 14px 10px;
    font-size: 12.5px;
    line-height: 1.5;
    color: var(--text-3);
}

.tree { list-style: none; margin: 0; padding: 0; }
.tree--nested[hidden] { display: none; }

.tree__row {
    display: flex;
    align-items: center;
    gap: 2px;
    border-radius: var(--radius-sm);
    padding-left: calc(var(--depth, 0) * 14px);
    transition: background .13s;
}
.tree__row:hover { background: var(--surface-soft); }

.tree__row.is-active {
    background: var(--accent-soft);
}
.tree__row.is-active .tree__link { color: var(--accent-dark); font-weight: 600; }
.tree__row.is-active .tree__icon { color: var(--accent-dark); }

.tree__toggle {
    display: grid;
    place-items: center;
    width: 20px;
    height: 30px;
    border: 0;
    background: none;
    color: var(--text-3);
    cursor: pointer;
    flex: none;
    transition: transform .16s ease;
}
.tree__toggle.is-open { transform: rotate(90deg); }

.tree__spacer { width: 20px; flex: none; }

.tree__link {
    display: flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
    flex: 1;
    padding: 7px 8px 7px 2px;
    font-size: 13.5px;
    color: var(--text-2);
}
.tree__link span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tree__icon { color: #f0b64b; flex: none; }

/* storage meter */
.storage {
    padding: 14px 18px 18px;
    border-top: 1px solid var(--line);
}

.storage__head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 12.5px;
    color: var(--text-2);
    margin-bottom: 8px;
}
.storage__head strong { font-size: 12.5px; color: var(--text); }

.storage__bar {
    height: 6px;
    border-radius: 999px;
    background: var(--surface-sunk);
    overflow: hidden;
}
.storage__bar span {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #c86ee6, var(--accent));
    transition: width .4s ease;
}

.storage__text {
    margin: 8px 0 0;
    font-size: 11.5px;
    color: var(--text-3);
}

/* ---------------------------------------------------------------- main -- */

.main {
    grid-area: main;
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    background: var(--surface-soft);
}

.main__bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 24px;
    flex: none;
}

.searchbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.search {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
}

.search__icon {
    position: absolute;
    left: 14px;
    color: var(--text-3);
    pointer-events: none;
}

.search input {
    width: 100%;
    height: 40px;
    padding: 0 38px 0 42px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-size: 13.5px;
    color: var(--text);
    box-shadow: var(--shadow-sm);
    transition: border-color .15s, box-shadow .15s;
}
.search input::placeholder { color: var(--text-3); }
.search input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.search input::-webkit-search-cancel-button { display: none; }

.search__clear {
    position: absolute;
    right: 12px;
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    color: var(--text-3);
    background: var(--surface-sunk);
}
.search__clear:hover { color: var(--text); }

/* buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 40px;
    padding: 0 18px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s, border-color .15s, box-shadow .15s, opacity .15s;
}
.btn:hover:not(:disabled) { background: var(--surface-soft); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn--primary {
    border-color: transparent;
    background: var(--accent);
    color: #fff;
    box-shadow: 0 2px 8px rgba(34, 181, 115, .3);
}
.btn--primary:hover:not(:disabled) { background: var(--accent-dark); }

.btn--danger {
    border-color: transparent;
    background: var(--danger);
    color: #fff;
}
/* Has to match the specificity of `.btn:hover:not(:disabled)` above, or that
   rule repaints the background near-white and leaves white text on it. */
.btn--danger:hover:not(:disabled) {
    background: var(--danger-strong);
    color: #fff;
}

.btn--block { width: 100%; }

/* square icon-only button */
.btn--icon {
    width: 40px;
    padding: 0;
    flex: none;
}

/* Upload sits in the sidebar; the toolbar copy only appears once the
   sidebar is hidden on narrow screens. */
.main__bar-upload { display: none; }

.sidebar__actions {
    padding: 16px 12px 4px;
}

/* content */
.main__scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0 24px 32px;
}

.crumbs {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    margin-bottom: 18px;
    font-size: 12.5px;
    color: var(--text-3);
}
.crumbs a { color: var(--text-2); }
.crumbs a:hover { color: var(--accent-dark); }
.crumbs span[aria-current] { color: var(--text); font-weight: 600; }
.crumbs__sep { color: var(--line-strong); }

.section { margin-bottom: 28px; }

.section__title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 14px;
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.section__count {
    display: inline-grid;
    place-items: center;
    min-width: 22px;
    height: 20px;
    padding: 0 7px;
    border-radius: 999px;
    background: var(--surface-sunk);
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-3);
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(116px, 1fr));
    gap: 12px;
}

/* cards */
.card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 16px 10px 14px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: transparent;
    text-align: center;
    cursor: pointer;
    transition: background .15s, border-color .15s, box-shadow .15s, transform .15s;
}
.card:hover {
    background: var(--surface);
    border-color: var(--line);
    box-shadow: var(--shadow-sm);
}
.card.is-selected {
    background: var(--surface);
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.card__thumb {
    display: grid;
    place-items: center;
    width: 100%;
    height: 62px;
    margin-bottom: 8px;
}

.card__img {
    max-width: 100%;
    max-height: 62px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    box-shadow: var(--shadow-sm);
}

.card__name {
    width: 100%;
    font-size: 12.5px;
    font-weight: 500;
    line-height: 1.35;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.card__meta {
    font-size: 11px;
    color: var(--text-3);
}

.card--add {
    justify-content: center;
    border: 1.5px dashed var(--line-strong);
    color: var(--text-3);
    background: transparent;
}
.card--add:hover {
    border-color: var(--accent);
    color: var(--accent-dark);
    background: var(--accent-soft);
    box-shadow: none;
}
.card__plus {
    display: grid;
    place-items: center;
    height: 62px;
    margin-bottom: 8px;
}

/* file type mark */
.filemark {
    position: relative;
    display: grid;
    place-items: center;
    width: 44px;
    height: 54px;
}
.filemark__sheet {
    position: absolute;
    inset: 0;
    width: 44px;
    height: 54px;
    filter: drop-shadow(0 2px 5px rgba(20, 28, 45, .09));
}
.filemark__label {
    position: relative;
    margin-top: 8px;
    padding: 2px 5px;
    border-radius: 4px;
    background: var(--mark, #9aa1ad);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .02em;
    line-height: 1.35;
    max-width: 38px;
    overflow: hidden;
}

/* empty state */
.empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 44px 20px;
    border: 1.5px dashed var(--line-strong);
    border-radius: var(--radius-lg);
    color: var(--text-3);
    text-align: center;
}
.empty p { margin: 0; font-size: 13px; max-width: 42ch; }

/* drag & drop veil */
.dropveil {
    position: absolute;
    inset: 12px;
    display: grid;
    place-items: center;
    border: 2px dashed var(--accent);
    border-radius: var(--radius-lg);
    background: rgba(230, 247, 239, .92);
    backdrop-filter: blur(2px);
    z-index: 20;
    pointer-events: none;
}
.dropveil[hidden] { display: none; }
.dropveil__inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    color: var(--accent-dark);
    font-weight: 600;
}
.dropveil p { margin: 0; }

/* ------------------------------------------------------------- details -- */

.details {
    grid-area: details;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow-y: auto;
    padding: 22px 20px;
    background: var(--surface);
    border-left: 1px solid var(--line);
}

.details__empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin: auto;
    color: var(--text-3);
    text-align: center;
}
.details__empty p { margin: 0; font-size: 12.5px; max-width: 22ch; }

.details__body[hidden] { display: none; }

.details__preview {
    display: grid;
    place-items: center;
    height: 108px;
    margin-bottom: 14px;
}
.details__preview img {
    max-width: 100%;
    max-height: 108px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.details__name {
    margin: 0 0 20px;
    font-size: 15px;
    font-weight: 600;
    text-align: center;
    line-height: 1.35;
    word-break: break-word;
}

.details__label {
    margin: 0 0 10px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: var(--text-3);
}

.details__list { margin: 0 0 22px; }
.details__list > div {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 7px 0;
    border-bottom: 1px solid var(--line);
}
.details__list > div[hidden] { display: none; }
.details__list dt {
    font-size: 12.5px;
    color: var(--text-3);
    flex: none;
}
.details__list dd {
    margin: 0;
    font-size: 12.5px;
    font-weight: 500;
    text-align: right;
    overflow-wrap: anywhere;
}
.details__link { color: var(--accent-dark); }

.details__actions {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.action {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 10px;
    border: 0;
    border-radius: var(--radius-sm);
    background: none;
    font-size: 13px;
    color: var(--text-2);
    text-align: left;
    cursor: pointer;
    transition: background .13s, color .13s;
}
.action:hover { background: var(--surface-soft); color: var(--text); }
.action[hidden] { display: none; }

.action--danger { color: var(--danger); }
.action--danger:hover { background: var(--danger-soft); color: var(--danger); }

.details__note {
    margin: 0;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: var(--surface-soft);
    font-size: 12.5px;
    line-height: 1.5;
    color: var(--text-3);
}

/* read-only marker where the Upload button would be */
.readonly-note {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 40px;
    padding: 0 14px;
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    color: var(--text-3);
    white-space: nowrap;
}

/* =========================================================================
   Search results: name matches vs content matches
   ========================================================================= */

.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--line-strong);
}

.tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    margin-bottom: -1px;
    border: 0;
    border-bottom: 2px solid transparent;
    background: none;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text-3);
    cursor: pointer;
    white-space: nowrap;
    transition: color .15s, border-color .15s;
}
.tab:hover { color: var(--text-2); }

.tab.is-active {
    color: var(--accent-dark);
    border-bottom-color: var(--accent);
}

.tab__count {
    display: inline-grid;
    place-items: center;
    min-width: 20px;
    height: 19px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--surface-sunk);
    font-size: 11px;
    font-weight: 600;
}
.tab.is-active .tab__count { background: var(--accent-soft); color: var(--accent-dark); }

.tabpanel { display: none; }
.tabpanel.is-active { display: block; }

.notice {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    margin-bottom: 16px;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    background: #fff6e6;
    font-size: 12.5px;
    line-height: 1.5;
    color: #8a5a12;
}
.notice svg { flex: none; margin-top: 1px; }
.notice a { color: #7a4f0d; font-weight: 600; text-decoration: underline; }

/* content hit list */
.hits { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }

.hit {
    display: flex;
    gap: 14px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    transition: border-color .15s, box-shadow .15s;
}
.hit:hover { border-color: var(--line-strong); box-shadow: var(--shadow-sm); }

.hit__mark {
    display: grid;
    place-items: center;
    width: 38px;
    height: 46px;
    flex: none;
    border-radius: 6px;
    background: var(--mark, #9aa1ad);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .02em;
}

.hit__body { min-width: 0; flex: 1; }

.hit__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}

.hit__name {
    font-size: 13.5px;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.hit__meta { font-size: 11.5px; color: var(--text-3); white-space: nowrap; }

.hit__snippet {
    margin: 0 0 9px;
    padding: 9px 11px;
    border-radius: var(--radius-sm);
    background: var(--surface-soft);
    font-size: 12.5px;
    line-height: 1.6;
    color: var(--text-2);
    overflow-wrap: anywhere;
}

.hit__snippet mark {
    padding: 1px 3px;
    border-radius: 3px;
    background: #ffeaa0;
    color: #6b4d00;
    font-weight: 600;
}

.hit__links { display: flex; flex-wrap: wrap; gap: 14px; }
.hit__links a {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: var(--text-3);
}
.hit__links a:hover { color: var(--accent-dark); }

/* index status */
.statgrid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.stat {
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    text-align: center;
}
.stat strong { display: block; font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.stat span { font-size: 11.5px; color: var(--text-3); }
.stat--ok strong   { color: var(--accent-dark); }
.stat--warn strong { color: #b5811f; }

.progress { margin-bottom: 16px; }
.progress__bar {
    height: 8px;
    border-radius: 999px;
    background: var(--surface-sunk);
    overflow: hidden;
}
.progress__bar span {
    display: block;
    height: 100%;
    width: 0;
    border-radius: 999px;
    background: linear-gradient(90deg, #c86ee6, var(--accent));
    transition: width .3s ease;
}
.progress__text { margin: 9px 0 0; font-size: 12.5px; color: var(--text-2); }

.page__inner--narrow { max-width: 720px; }

/* files that hold no readable text */
.whylist { list-style: none; margin: 0; padding: 0; }
.whylist li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 0;
    border-bottom: 1px solid var(--line);
}
.whylist li:last-child { border-bottom: 0; }

.whylist__mark {
    display: grid;
    place-items: center;
    width: 30px;
    height: 36px;
    flex: none;
    border-radius: 5px;
    background: var(--mark, #9aa1ad);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
}

.whylist__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.whylist__text a {
    font-size: 13px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.whylist__text a:hover { color: var(--accent-dark); }
.whylist__text small { font-size: 11.5px; color: var(--text-3); }

.whylist__size { font-size: 11.5px; color: var(--text-3); flex: none; }

@media (max-width: 620px) {
    .statgrid { grid-template-columns: repeat(2, 1fr); }
    .hit { flex-direction: column; gap: 10px; }
    .hit__mark { width: 34px; height: 40px; }
}

/* =========================================================================
   User management
   ========================================================================= */

.app--plain {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
        "topbar"
        "main";
    background: var(--surface-soft);
}

.page {
    grid-area: main;
    min-height: 0;
    overflow-y: auto;
    padding: 28px 24px 48px;
}

.page__inner { max-width: 1080px; margin: 0 auto; }

.page__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.page__title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 6px;
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.015em;
}
.page__title svg { color: var(--accent-dark); }

.page__lead {
    margin: 0;
    font-size: 13.5px;
    color: var(--text-2);
    max-width: 62ch;
}

.page__foot {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 18px 2px 0;
    font-size: 12.5px;
    line-height: 1.55;
    color: var(--text-3);
}
.page__foot svg { flex: none; margin-top: 2px; }

.btn--ghost {
    border-color: var(--line);
    background: var(--surface);
    color: var(--text-2);
}

.tablewrap {
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    min-width: 860px;
}

.table thead th {
    padding: 13px 16px;
    border-bottom: 1px solid var(--line);
    background: var(--surface-soft);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--text-3);
    text-align: left;
    white-space: nowrap;
}

.table tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-soft); }

.table tbody tr.is-suspended td { opacity: .55; }

.table__num { text-align: right; white-space: nowrap; }
.table__num strong { display: block; font-size: 13px; }
.table__num .muted { font-size: 11.5px; }

.table__actions { text-align: right; white-space: nowrap; }

.who { display: flex; align-items: center; gap: 11px; }
.who__text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.who__text strong {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 13.5px;
    font-weight: 600;
}
.who__text span {
    font-size: 12px;
    color: var(--text-3);
    overflow: hidden;
    text-overflow: ellipsis;
}

.avatar--admin { background: #6b57e8; }
.avatar--user  { background: #8d97a8; }

.tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .01em;
    white-space: nowrap;
}
.tag--admin { background: #efeaff; color: #5a45d6; }
.tag--plain { background: var(--surface-sunk); color: var(--text-2); }
.tag--ok    { background: var(--accent-soft); color: var(--accent-dark); }
.tag--off   { background: #fdf0e3; color: #a76a1c; }
.tag--you   { background: var(--surface-sunk); color: var(--text-3); font-weight: 500; }

.permrow { display: flex; flex-wrap: wrap; gap: 5px; }

.permchip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-3);
    background: var(--surface);
    white-space: nowrap;
}
.permchip.is-on {
    border-color: transparent;
    background: var(--accent-soft);
    color: var(--accent-dark);
}
.permchip.is-all { background: #efeaff; color: #5a45d6; }

.permnote {
    display: block;
    margin-top: 5px;
    font-size: 11px;
    color: var(--text-3);
}

.iconbtn {
    display: inline-grid;
    place-items: center;
    width: 32px;
    height: 32px;
    margin-left: 2px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--text-3);
    cursor: pointer;
    transition: background .13s, color .13s, border-color .13s;
}
.iconbtn:hover:not(:disabled) {
    background: var(--surface-sunk);
    border-color: var(--line-strong);
    color: var(--text);
}
.iconbtn:disabled { opacity: .35; cursor: not-allowed; }
.iconbtn--danger:hover:not(:disabled) {
    background: var(--danger-soft);
    border-color: transparent;
    color: var(--danger);
}

/* role + permission summary inside the account dropdown */
.menu__role {
    margin-top: 4px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--accent-dark);
}

.menu__perms {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 0 12px 10px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--line);
}

/* permission picker inside the add/edit dialog */
.fieldrow {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-bottom: 14px;
}
.fieldrow[hidden] { display: none; }

.permbox {
    margin-top: 6px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-soft);
}

.permbox__title {
    margin: 0 0 4px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-3);
}

.permbox__lead {
    margin: 0 0 12px;
    font-size: 12.5px;
    color: var(--text-2);
}

.permbox__rule {
    margin: 12px 0;
    border: 0;
    border-top: 1px solid var(--line-strong);
}

.permopt {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 7px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background .13s;
}
.permopt:hover { background: var(--surface); }
.permopt[hidden] { display: none; }

.permopt input {
    margin-top: 2px;
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    flex: none;
    cursor: pointer;
}
.permopt input:disabled { cursor: not-allowed; }

.permopt__text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.permopt__text strong {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
}
.permopt__text span { font-size: 12px; color: var(--text-3); line-height: 1.45; }

.permopt--admin .permopt__text strong { color: #5a45d6; }

/* while Administrator is ticked the individual boxes are forced on */
.modal.is-admin .permopt input:disabled + .permopt__text { opacity: .55; }

.modal--wide { width: min(560px, calc(100vw - 32px)); }

.modal__warn {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 14px 0 0;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: var(--danger-soft);
    font-size: 12.5px;
    line-height: 1.5;
    color: #a3373b;
}
.modal__warn svg { flex: none; margin-top: 1px; }

/* storage meter escalation */
.storage__bar span.is-warn     { background: linear-gradient(90deg, #f0b64b, #e89b2c); }
.storage__bar span.is-critical { background: linear-gradient(90deg, #ef6f72, var(--danger)); }

.storage__text--sub { margin-top: 3px; color: var(--text-3); opacity: .85; }

.rail__item--foot { margin-top: auto; }

/* count badge on the recycle bin */
.rail__dot {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 17px;
    text-align: center;
}

/* =========================================================================
   Password-protected folders
   ========================================================================= */

.card--folder.is-protected .card__meta { color: var(--text-2); font-weight: 500; }

.tree__lock {
    flex: none;
    margin-left: 4px;
    color: var(--text-3);
}
.tree__lock.is-open { color: var(--accent); }

.lockmark svg { filter: drop-shadow(0 2px 6px rgba(20, 28, 45, .12)); }

.auth__note {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 16px 0 0;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: var(--surface-soft);
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-3);
}
.auth__note svg { flex: none; margin-top: 2px; }

/* =========================================================================
   Recycle bin
   ========================================================================= */

.inlineform { display: inline; }

.tag--plain svg, .tag--off svg { flex: none; }

/* =========================================================================
   Overlays
   ========================================================================= */

.toasts {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 60;
    pointer-events: none;
}

.toast {
    padding: 11px 18px;
    border-radius: 999px;
    background: #1e2430;
    color: #fff;
    font-size: 13px;
    box-shadow: var(--shadow-lg);
    animation: toast-in .22s ease;
}
.toast--error { background: var(--danger); }

@keyframes toast-in {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: none; }
}

/* upload tray */
.uploads {
    position: fixed;
    right: 22px;
    bottom: 22px;
    width: 320px;
    max-height: 46vh;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    z-index: 55;
    overflow: hidden;
}
.uploads[hidden] { display: none; }

.uploads__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    font-size: 13px;
}

.uploads__close {
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border: 0;
    border-radius: 6px;
    background: none;
    color: var(--text-3);
    cursor: pointer;
}
.uploads__close:hover { background: var(--surface-soft); }

.uploads__list {
    list-style: none;
    margin: 0;
    padding: 8px;
    overflow-y: auto;
}

.uploads__item { padding: 8px 6px; }
.uploads__row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    font-size: 12.5px;
    margin-bottom: 6px;
}
.uploads__name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.uploads__state { color: var(--text-3); flex: none; font-size: 11.5px; }
.uploads__item.is-error .uploads__state { color: var(--danger); }
.uploads__item.is-done  .uploads__state { color: var(--accent-dark); }

.uploads__bar {
    height: 4px;
    border-radius: 999px;
    background: var(--surface-sunk);
    overflow: hidden;
}
.uploads__bar span {
    display: block;
    height: 100%;
    width: 0;
    border-radius: 999px;
    background: var(--accent);
    transition: width .2s ease;
}
.uploads__item.is-error .uploads__bar span { background: var(--danger); }

/* right-click menu */
.ctxmenu {
    position: fixed;
    z-index: 70;
    min-width: 190px;
    padding: 5px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    animation: ctx-in .1s ease;
}
.ctxmenu[hidden] { display: none; }

@keyframes ctx-in {
    from { opacity: 0; transform: scale(.97); }
    to   { opacity: 1; transform: none; }
}

.ctxmenu__item {
    display: flex;
    align-items: center;
    gap: 11px;
    width: 100%;
    padding: 8px 11px;
    border: 0;
    border-radius: var(--radius-sm);
    background: none;
    font-size: 13px;
    color: var(--text-2);
    text-align: left;
    white-space: nowrap;
    cursor: pointer;
}
.ctxmenu__item svg { flex: none; color: var(--text-3); }
.ctxmenu__item:hover,
.ctxmenu__item:focus-visible {
    background: var(--surface-soft);
    color: var(--text);
    outline: none;
}
.ctxmenu__item:hover svg,
.ctxmenu__item:focus-visible svg { color: var(--accent-dark); }

.ctxmenu__item.is-danger { color: var(--danger); }
.ctxmenu__item.is-danger svg { color: var(--danger); }
.ctxmenu__item.is-danger:hover,
.ctxmenu__item.is-danger:focus-visible { background: var(--danger-soft); color: var(--danger); }
.ctxmenu__item.is-danger:hover svg { color: var(--danger); }

.ctxmenu__rule {
    height: 1px;
    margin: 5px 6px;
    background: var(--line);
}

/* modals */
.modal {
    width: min(420px, calc(100vw - 32px));
    padding: 0;
    border: 0;
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    color: var(--text);
}
.modal::backdrop {
    background: rgba(20, 28, 45, .38);
    backdrop-filter: blur(2px);
}

.modal__form { padding: 24px; }

.modal__title {
    margin: 0 0 6px;
    font-size: 17px;
    font-weight: 600;
}

.modal__note {
    margin: 0 0 18px;
    font-size: 13px;
    color: var(--text-2);
    overflow-wrap: anywhere;
}

.modal__actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 22px;
}

/* =========================================================================
   Forms
   ========================================================================= */

.form { display: flex; flex-direction: column; gap: 16px; }

.field { display: block; }

.field__label {
    display: block;
    margin-bottom: 6px;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text-2);
}

.field__control {
    position: relative;
    display: flex;
    align-items: center;
}

.field__icon {
    position: absolute;
    left: 13px;
    color: var(--text-3);
    pointer-events: none;
}

.field input,
.select {
    width: 100%;
    height: 42px;
    padding: 0 14px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-size: 14px;
    color: var(--text);
    transition: border-color .15s, box-shadow .15s;
}
.field__icon ~ input { padding-left: 40px; }

.field input:focus,
.select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2399a1ae' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 9 7 7 7-7'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 13px center;
    padding-right: 38px;
}


.alert {
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 4px;
}
.alert--ok    { background: var(--accent-soft); color: var(--accent-dark); }
.alert--error { background: var(--danger-soft); color: #b42d31; }

/* =========================================================================
   Sign in / register
   ========================================================================= */

.auth-body {
    display: grid;
    place-items: center;
    padding: 32px 16px;
    background:
        radial-gradient(1100px 480px at 12% -8%, #d9f3e6 0%, transparent 62%),
        radial-gradient(900px 460px at 92% 8%, #e4ecff 0%, transparent 58%),
        var(--page);
}

.auth {
    width: min(420px, 100%);
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.auth__brand { text-align: center; }
.auth__logo {
    display: inline-grid;
    place-items: center;
    width: 56px;
    height: 56px;
    border-radius: 18px;
    background: var(--surface);
    box-shadow: var(--shadow);
    margin-bottom: 14px;
}
.auth__brand h1 {
    margin: 0 0 4px;
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.015em;
}
.auth__brand p { margin: 0; font-size: 13.5px; color: var(--text-2); }

.auth__card {
    padding: 28px;
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow);
}
.auth__card h2 {
    margin: 0 0 4px;
    font-size: 18px;
    font-weight: 600;
}
.auth__lead {
    margin: 0 0 20px;
    font-size: 13px;
    color: var(--text-2);
}

.auth__switch {
    margin: 18px 0 0;
    font-size: 13px;
    color: var(--text-2);
    text-align: center;
}
.auth__switch a { color: var(--accent-dark); font-weight: 500; }
.auth__switch a:hover { text-decoration: underline; }
/* =========================================================================
   Shell variants and mobile navigation
   ========================================================================= */

/* Admin screens: same shell, no details panel. */
.app--nodetails {
    grid-template-columns: var(--rail) var(--sidebar) minmax(0, 1fr);
    grid-template-areas:
        "topbar topbar  topbar"
        "rail   sidebar main";
}

/* Hamburger — only appears once the sidebar becomes a drawer. */
.topbar__burger {
    display: none;
    place-items: center;
    width: 40px;
    height: 40px;
    margin-right: -6px;
    border: 0;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--text-2);
    cursor: pointer;
    flex: none;
}
.topbar__burger:hover { background: var(--surface-soft); color: var(--text); }

/* Labels beside the rail icons, shown only in the mobile drawer. */
.rail__label { display: none; }

/* Dim the page behind the drawer. */
.scrim {
    position: fixed;
    inset: var(--topbar) 0 0 0;
    z-index: 44;
    background: rgba(20, 28, 45, .38);
    border: 0;
    padding: 0;
    animation: scrim-in .18s ease;
}
.scrim[hidden] { display: none; }

@keyframes scrim-in { from { opacity: 0; } to { opacity: 1; } }

/* =========================================================================
   Tablet — the details panel slides over instead of taking a column
   ========================================================================= */

@media (max-width: 1180px) {
    .app:not(.app--nodetails) {
        grid-template-columns: var(--rail) var(--sidebar) minmax(0, 1fr);
        grid-template-areas:
            "topbar topbar  topbar"
            "rail   sidebar main";
    }

    .details {
        position: fixed;
        top: var(--topbar);
        right: 0;
        bottom: 0;
        width: var(--details);
        z-index: 46;
        box-shadow: var(--shadow-lg);
        transform: translateX(100%);
        transition: transform .22s ease;
    }
    .details.is-open { transform: none; }
}

/* =========================================================================
   Small tablet and phone — rail and sidebar become one drawer
   ========================================================================= */

@media (max-width: 900px) {
    /* Specificity has to match the 1180px rule above, or that one wins here
       too and the rail and sidebar keep their columns. */
    .app:not(.app--nodetails),
    .app.app--nodetails {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas:
            "topbar"
            "main";
    }

    .topbar__burger { display: grid; }
    .topbar { padding: 0 12px; gap: 10px; }
    .topbar__usage { display: none; }
    .topbar__back span { display: none; }
    .topbar__back { width: 40px; padding: 0; justify-content: center; }
    .chip__name { display: none; }
    .chip { padding: 4px; border-color: transparent; }

    /* Both panels slide in together as one navigation drawer. */
    .rail,
    .sidebar {
        position: fixed;
        top: var(--topbar);
        bottom: 0;
        z-index: 45;
        transform: translateX(-100%);
        transition: transform .22s ease;
    }
    .rail    { left: 0; width: var(--rail); }
    .sidebar { left: var(--rail); width: var(--sidebar); box-shadow: var(--shadow-lg); }

    .app.is-nav-open .rail,
    .app.is-nav-open .sidebar { transform: none; }

    /* There is no hover on touch, so the drawer spells the rail icons out. */
    .app.is-nav-open .rail {
        width: 164px;
        align-items: stretch;
        padding: 12px 10px;
    }
    .app.is-nav-open .rail__item {
        display: flex;
        align-items: center;
        gap: 12px;
        width: 100%;
        height: 42px;
        padding: 0 12px;
        border-radius: var(--radius-sm);
    }
    .app.is-nav-open .rail__item.is-active::before { left: 0; }
    .app.is-nav-open .rail__label {
        display: block;
        font-size: 13px;
        font-weight: 500;
        white-space: nowrap;
    }
    .app.is-nav-open .rail__dot { top: 6px; right: 8px; }
    .app.is-nav-open .sidebar { left: 164px; }

    .main__bar { padding: 12px 14px; }
    .main__scroll { padding: 0 14px 24px; }
    .page { padding: 20px 14px 40px; }

    /* Upload lives in the drawer, so keep the toolbar copy reachable. */
    .main__bar-upload { display: inline-flex; }
    .searchbar__go { width: 40px; padding: 0; }
    .searchbar__go span { display: none; }

    .details { width: min(320px, 88vw); }
}

@media (max-width: 640px) {
    :root { --rail: 56px; --sidebar: 200px; }

    .topbar__title { display: none; }
    .page__head { flex-direction: column; align-items: stretch; }
    .page__head .btn { width: 100%; justify-content: center; }
    .fieldrow { grid-template-columns: 1fr; }
    .statgrid { grid-template-columns: repeat(2, 1fr); }

    .grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
    .card { padding: 12px 6px 10px; }
    .card__thumb { height: 54px; }
    .section__title { font-size: 15.5px; }

    .uploads { right: 10px; left: 10px; width: auto; }
    .toasts { left: 12px; right: 12px; transform: none; }
    .toast { text-align: center; }

    .modal { width: min(420px, calc(100vw - 20px)); }
    .modal__form { padding: 20px; }
    .modal__actions { flex-direction: column-reverse; }
    .modal__actions .btn { width: 100%; }

    .hit { flex-direction: column; gap: 10px; }
    .tabs { gap: 0; }
    .tab { padding: 10px 10px; font-size: 12.5px; }

    /* Fingers need a bigger target than a mouse pointer. */
    .iconbtn { width: 38px; height: 38px; }
    .ctxmenu__item { padding: 11px 12px; font-size: 13.5px; }
    .action { padding: 11px 10px; }
    .tree__link { padding-top: 9px; padding-bottom: 9px; }
    .rail__item { width: 40px; height: 40px; }
}

/* Coarse pointers get no hover, so the long-press menu is the way in. */
@media (pointer: coarse) {
    .card { -webkit-touch-callout: none; }
    .ctxmenu { min-width: 210px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        transition-duration: .001ms !important;
    }
}

.empty__aside {
    margin: 4px 0 0;
    padding-top: 10px;
    border-top: 1px solid var(--line-strong);
    font-size: 12px;
    line-height: 1.55;
    max-width: 46ch;
}
.empty__aside a { color: var(--accent-dark); text-decoration: underline; }

/* =========================================================================
   Sync devices
   ========================================================================= */

.tokenbox {
    margin-bottom: 18px;
    padding: 18px;
    border: 1px solid var(--accent);
    border-radius: var(--radius-lg);
    background: var(--accent-soft);
}

.tokenbox__title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 4px;
    font-size: 14px;
    font-weight: 600;
    color: var(--accent-dark);
}

.tokenbox__lead {
    margin: 0 0 12px;
    font-size: 12.5px;
    line-height: 1.55;
    color: var(--text-2);
}
.tokenbox__lead code {
    padding: 1px 5px;
    border-radius: 4px;
    background: var(--surface);
    font-size: 12px;
}

.tokenbox__value {
    display: flex;
    align-items: stretch;
    gap: 8px;
}
.tokenbox__value code {
    flex: 1;
    min-width: 0;
    padding: 10px 12px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-family: ui-monospace, Consolas, monospace;
    font-size: 12.5px;
    overflow-wrap: anywhere;
    user-select: all;
}

.steps--ordered {
    counter-reset: step;
    list-style: none;
    margin: 0;
    padding: 0;
}
.steps--ordered li {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 8px 0;
    border-bottom: 1px solid var(--line);
    font-size: 13px;
    line-height: 1.55;
}
.steps--ordered li:last-child { border-bottom: 0; }
.steps--ordered li::before {
    counter-increment: step;
    content: counter(step);
    display: grid;
    place-items: center;
    flex: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent-dark);
    font-size: 11.5px;
    font-weight: 700;
}
.steps--ordered code {
    padding: 1px 5px;
    border-radius: 4px;
    background: var(--surface-sunk);
    font-size: 12px;
}

/* =========================================================================
   Activity timeline
   ========================================================================= */

.page__headactions { display: flex; gap: 8px; flex-wrap: wrap; }

.statcard {
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}
.statcard__label {
    display: block;
    font-size: 11.5px;
    color: var(--text-3);
    margin-bottom: 4px;
}
.statcard__value {
    display: block;
    font-size: 24px;
    font-weight: 600;
    letter-spacing: -0.02em;
}
.statcard__value--sm { font-size: 16px; padding: 4px 0; }

/* filter bar */
.filterbar {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    flex-wrap: wrap;
    margin: 18px 0;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}
.filterbar__field { display: flex; flex-direction: column; gap: 5px; min-width: 150px; }
.filterbar__field--grow { flex: 1 1 220px; }
.filterbar__field--date { min-width: 132px; }
.filterbar__label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--text-3);
}
.filterbar__field input,
.filterbar__field select {
    width: 100%;
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font: inherit;
    font-size: 13px;
    color: var(--text);
}
.filterbar__field input:focus,
.filterbar__field select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.filterbar__actions { display: flex; gap: 8px; margin-left: auto; }

.resultcount {
    margin: 0 2px 12px;
    font-size: 12.5px;
    color: var(--text-3);
}

/* the timeline itself */
.timeline {
    position: relative;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.timeline__day {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 18px;
    background: var(--surface-sunk);
    border-bottom: 1px solid var(--line);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-2);
    position: sticky;
    top: 0;
    z-index: 1;
}
.timeline__day time { font-weight: 400; color: var(--text-3); }

.event {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 18px;
    border-bottom: 1px solid var(--line);
}
.event:last-child { border-bottom: 0; }
.event:hover { background: var(--surface-soft); }

/* The mark is colour-coded by what kind of thing happened, so a run of
   deletions stands out from a run of downloads without having to be read. */
.event__mark {
    display: grid;
    place-items: center;
    flex: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--surface-sunk);
    color: var(--text-2);
}
.event--sessions .event__mark       { background: #eef2fb; color: #3f6bc4; }
.event--access .event__mark         { background: var(--surface-sunk); color: var(--text-2); }
.event--changes .event__mark        { background: var(--accent-soft); color: var(--accent-dark); }
.event--deletion .event__mark       { background: var(--danger-soft); color: var(--danger-strong); }
.event--security .event__mark       { background: #fdf3e3; color: #a1710f; }
.event--administration .event__mark { background: #f1ecfb; color: #6d4fb8; }
.event--sync .event__mark           { background: #e7f4f8; color: #22738d; }

.event__body { flex: 1 1 auto; min-width: 0; }
.event__line {
    margin: 0;
    font-size: 13.5px;
    line-height: 1.5;
}
.event__who  { font-weight: 600; }
.event__what { color: var(--text-2); }
.event__target {
    display: inline-block;
    max-width: 100%;
    padding: 1px 7px;
    border-radius: 5px;
    background: var(--surface-sunk);
    font-size: 12.5px;
    vertical-align: baseline;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.event__detail {
    margin: 3px 0 0;
    font-size: 12px;
    color: var(--text-3);
    overflow-wrap: anywhere;
}

.event__meta {
    flex: none;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    font-size: 11.5px;
    color: var(--text-3);
    white-space: nowrap;
}
.event__from { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; }

.pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 16px;
}
.pager__at { font-size: 12.5px; color: var(--text-3); }
.pager .btn[aria-disabled="true"] { opacity: .45; pointer-events: none; }

@media (max-width: 900px) {
    .statgrid { grid-template-columns: repeat(2, 1fr); }
    .filterbar__actions { margin-left: 0; width: 100%; }
}

@media (max-width: 640px) {
    .page__headactions { width: 100%; }
    .page__headactions .btn { flex: 1 1 auto; justify-content: center; }
    .filterbar__field { min-width: 0; flex: 1 1 140px; }
    /* Stacked, so a long file name is not fighting the timestamp for room. */
    .event { flex-wrap: wrap; }
    .event__meta {
        width: 100%;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        padding-left: 42px;
    }
}

/* =========================================================================
   Tamil typing — தமிழ்
   ========================================================================= */

.langtoggle {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 34px;
    padding: 0 12px 0 8px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text-2);
    cursor: pointer;
    transition: background .12s, border-color .12s, color .12s;
}
.langtoggle:hover { border-color: var(--accent); color: var(--text); }

.langtoggle__mark {
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--surface-sunk);
    font-size: 13px;
    line-height: 1;
    /* The அ is the whole point of the control, so give it the Tamil face
       directly rather than relying on the fallback chain. */
    font-family: "Noto Sans Tamil", "Nirmala UI", "Latha", "Tamil Sangam MN", sans-serif;
}
.langtoggle__text { font-size: 12.5px; font-weight: 500; }

.langtoggle.is-on {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent-dark);
}
.langtoggle.is-on .langtoggle__mark { background: var(--accent); color: #fff; }

/* While Tamil is on, every box it applies to says so. */
body.is-tamil input[type="text"],
body.is-tamil input[type="search"],
body.is-tamil textarea {
    border-color: var(--accent);
    box-shadow: inset 3px 0 0 var(--accent);
}
body.is-tamil input[data-no-tamil],
body.is-tamil textarea[data-no-tamil] {
    border-color: var(--line-strong);
    box-shadow: none;
}

/* the letter pad */
.tamilpad {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 60;
    width: min(560px, calc(100vw - 32px));
    max-height: min(60vh, 520px);
    display: flex;
    flex-direction: column;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}
.tamilpad[hidden] { display: none; }

.tamilpad__head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px 10px 16px;
    border-bottom: 1px solid var(--line);
    background: var(--surface-soft);
}
.tamilpad__title { font-size: 14px; }
.tamilpad__title span { font-size: 11.5px; font-weight: 400; color: var(--text-3); margin-left: 6px; }

.tamilpad__tabs { display: flex; gap: 4px; margin-left: auto; }
.tamilpad__tab {
    padding: 5px 11px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    font-size: 12.5px;
    color: var(--text-2);
    cursor: pointer;
}
.tamilpad__tab.is-on { background: var(--accent-soft); color: var(--accent-dark); font-weight: 600; }

.tamilpad__body { padding: 14px 16px 18px; overflow-y: auto; }
.tamilpad__body[hidden] { display: none; }

.tamilpad__hint {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0 0 12px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    background: var(--surface-sunk);
    font-size: 12px;
    color: var(--text-2);
}
.tamilpad__lead { margin: 0 0 14px; font-size: 13px; line-height: 1.6; color: var(--text-2); }

.padgroup { margin-bottom: 14px; }
.padgroup:last-child { margin-bottom: 0; }
.padgroup__title {
    margin: 0 0 7px;
    font-size: 12px;
    font-weight: 600;
    font-family: "Noto Sans Tamil", "Nirmala UI", "Latha", "Tamil Sangam MN", sans-serif;
}
.padgroup__title span {
    margin-left: 6px;
    font-weight: 400;
    font-size: 11px;
    color: var(--text-3);
    font-family: inherit;
}
.padgroup__row { display: flex; flex-wrap: wrap; gap: 5px; }

.padkey {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    padding: 5px 6px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    cursor: pointer;
    transition: background .1s, border-color .1s, transform .06s;
}
.padkey:hover  { border-color: var(--accent); background: var(--accent-soft); }
.padkey:active { transform: translateY(1px); }
.padkey__letter {
    font-size: 17px;
    line-height: 1.3;
    font-family: "Noto Sans Tamil", "Nirmala UI", "Latha", "Tamil Sangam MN", sans-serif;
}
.padkey__roman { font-size: 10px; color: var(--text-3); }

.padmap {
    display: inline-flex;
    align-items: baseline;
    gap: 5px;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    background: var(--surface-sunk);
}
.padmap__letter {
    font-size: 15px;
    font-family: "Noto Sans Tamil", "Nirmala UI", "Latha", "Tamil Sangam MN", sans-serif;
}
.padmap__roman { font-size: 11.5px; color: var(--text-3); }

.tamilpad__notes {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
    font-size: 12.5px;
    color: var(--text-2);
}
.tamilpad__notes p { margin: 0 0 6px; }
.tamilpad__notes ul { margin: 0; padding-left: 18px; line-height: 1.7; }
.tamilpad__notes code,
.tamilpad__lead code {
    padding: 1px 5px;
    border-radius: 4px;
    background: var(--surface-sunk);
    font-size: 11.5px;
}
.tamilpad kbd {
    padding: 1px 5px;
    border: 1px solid var(--line-strong);
    border-bottom-width: 2px;
    border-radius: 4px;
    background: var(--surface);
    font-size: 11px;
    font-family: inherit;
}

@media (max-width: 640px) {
    .langtoggle__text { display: none; }
    .langtoggle { padding: 0 8px; }
    /* On a phone the pad is the keyboard, so it takes the full width and sits
       flat against the bottom edge like one. */
    .tamilpad {
        right: 0;
        left: 0;
        bottom: 0;
        width: 100%;
        max-height: 58vh;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }
}

/* --- Security page ------------------------------------------------------ */

.setupkey {
    margin: 10px 0 14px;
}
.setupkey code {
    display: inline-block;
    padding: 10px 14px;
    background: var(--surface-sunk);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    font-size: 15px;
    letter-spacing: .12em;
    word-break: break-all;
}

/* Recovery codes are read off the screen and typed by hand, so they get room
   and a monospaced face rather than being packed into a paragraph. */
.codegrid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 8px;
    margin: 12px 0 4px;
}
.codegrid__item {
    padding: 9px 12px;
    background: var(--surface-sunk);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    font-size: 14px;
    letter-spacing: .08em;
    text-align: center;
}

/* A password box and its button on one line, for the confirm-then-act forms. */
.form--inline {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    flex-wrap: wrap;
    margin: 14px 0;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}
.form--inline .field { margin: 0; min-width: 220px; }

.btn--link {
    background: none;
    border: none;
    padding: 6px 0;
    color: var(--text-2);
    text-decoration: underline;
    cursor: pointer;
}
.btn--link:hover { color: var(--accent-dark); }

.kv {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 16px;
    margin: 0 0 14px;
    font-size: 13.5px;
}
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; color: var(--text); }

/* The enrolment QR. White plate and a quiet zone around it, because scanners
   need the margin and the page background is not white. */
.qrbox {
    display: inline-block;
    margin: 4px 0 16px;
    padding: 10px;
    background: #fff;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
}
.qrbox svg { display: block; }
