@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
    --bg: #0a0a0b;
    --panel: #131316;
    --line: #232328;
    --ink: #e7e7ea;
    --ink-soft: #7a7a80;
    --accent: #ff8200;

    /* tag palette, indexed 0-5 by data-color */
    --tag0-text: #7fb4ff; --tag0-line: rgba(127,180,255,0.35); --tag0-bg: rgba(127,180,255,0.08);
    --tag1-text: #ff9d3d; --tag1-line: rgba(255,157,61,0.4);  --tag1-bg: rgba(255,157,61,0.08);
    --tag2-text: #5fd99a; --tag2-line: rgba(95,217,154,0.35); --tag2-bg: rgba(95,217,154,0.08);
    --tag3-text: #ff8080; --tag3-line: rgba(255,128,128,0.35);--tag3-bg: rgba(255,128,128,0.08);
    --tag4-text: #c7a8ff; --tag4-line: rgba(199,168,255,0.35);--tag4-bg: rgba(199,168,255,0.08);
    --tag5-text: #b6b6bc; --tag5-line: rgba(182,182,188,0.3); --tag5-bg: rgba(182,182,188,0.06);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: 'akkurat-mono', 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--ink-soft);
    text-decoration: none;
}
a:hover { color: var(--ink); }

.wrap {
    max-width: 1080px;
    margin: 0 auto;
    padding: 28px 24px 96px;
}

.wrap--narrow {
    max-width: 320px;
    padding-top: 140px;
}

h1 {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    letter-spacing: 0.01em;
}

/* top bar */

.topbar {
    display: flex;
    align-items: center;
    gap: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 20px;
}

.topbar__link {
    margin-left: auto;
    font-size: 13px;
}
.topbar__link + .topbar__link { margin-left: 0; }

/* search bar */

.searchrow {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.searchbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 10px 18px;
}

.searchbar__icon {
    color: var(--ink-soft);
    flex: none;
}

.searchbar input {
    flex: 1;
    font-family: inherit;
    font-size: 14px;
    color: var(--ink);
    background: transparent;
    border: none;
}
.searchbar input::placeholder { color: var(--ink-soft); }
.searchbar input:focus { outline: none; }

.addBtn {
    flex: none;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: none;
    background: #fff;
    color: #0a0a0b;
    font-size: 19px;
    line-height: 1;
    cursor: pointer;
}
.addBtn:hover { background: var(--accent); color: #fff; }

/* tag filter row */

.tagrow {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 24px;
}

.tagpill {
    font-family: inherit;
    font-size: 12px;
    padding: 6px 14px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: transparent;
    color: var(--ink-soft);
    cursor: pointer;
}

.tagpill--all.is-active {
    background: #fff;
    border-color: #fff;
    color: #0a0a0b;
    font-weight: 600;
}

.tagpill[data-color] {
    color: var(--tag5-text);
    border-color: var(--tag5-line);
    background: var(--tag5-bg);
}

button.tagpill.is-active:not(.tagpill--all) {
    box-shadow: inset 0 0 0 1px currentColor;
}

.tagpill--static, .tagpill--edit, .tagpill--addnew {
    display: inline-block;
    margin-top: 16px;
}

.tagpill--addnew {
    color: var(--ink-soft);
    border-style: dashed;
}
.tagpill--addnew:hover {
    color: var(--ink);
    border-color: var(--ink-soft);
}

.tagpill--edit:hover {
    filter: brightness(1.3);
}

.modal__dialog--tag input[type="text"] {
    width: 100%;
    font-family: inherit;
    font-size: 14px;
    color: var(--ink);
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--line);
    padding-bottom: 8px;
}
.modal__dialog--tag input[type="text"]:focus {
    outline: none;
    border-color: var(--accent);
}

.tagModal__existing {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}

#tagRemove {
    margin-right: auto;
    color: var(--ink-soft);
}
#tagRemove:hover { color: #ff5c5c; }

/* masonry grid */

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
    align-items: start;
}

.card {
    display: flex;
    flex-direction: column;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 16px 18px;
    cursor: pointer;
    aspect-ratio: 6 / 4;
}

.grid--square .card {
    aspect-ratio: 6 / 5;
}

.card__top {
    flex: none;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
}

.card__meta {
    color: var(--ink-soft);
    font-size: 12px;
}

.card__body {
    flex: 1;
    min-height: 0;
    margin: 0;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-weight: 500;
    overflow: hidden;
    position: relative;
}
.card__body.is-truncated {
    -webkit-mask-image: linear-gradient(to bottom, #000 75%, transparent 100%);
    mask-image: linear-gradient(to bottom, #000 75%, transparent 100%);
}

.card > .tagpill--edit,
.card > .tagpill--addnew {
    flex: none;
    align-self: flex-start;
}

.menu {
    position: relative;
    flex: none;
}

.menuBtn {
    background: transparent;
    border: none;
    color: var(--ink-soft);
    padding: 2px 4px;
    border-radius: 6px;
    cursor: pointer;
    line-height: 0;
}
.menuBtn:hover {
    color: var(--ink);
    background: rgba(255,255,255,0.06);
}

.menuPanel {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 4px;
    min-width: 130px;
    box-shadow: 0 12px 28px rgba(0,0,0,0.45);
    z-index: 20;
}
.menuPanel[hidden] { display: none; }

.menuPanel .action {
    display: block;
    width: 100%;
    text-align: left;
    padding: 7px 10px;
    border-radius: 5px;
}
.menuPanel .action:hover {
    background: rgba(255,255,255,0.06);
}

.action {
    font-family: inherit;
    font-size: 12px;
    color: var(--ink-soft);
    background: transparent;
    border: none;
    padding: 0;
    cursor: pointer;
}
.action:hover { color: var(--ink); }
.action:disabled { opacity: 0.5; cursor: default; }
.action--danger:hover { color: #ff5c5c; }

.empty { color: var(--ink-soft); }

/* compose modal */

.modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 14vh;
    z-index: 10;
}
.modal[hidden] { display: none; }

.modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.6);
}

.modal__dialog {
    position: relative;
    width: 100%;
    max-width: 480px;
    margin: 0 24px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 18px;
}

.modal__dialog textarea {
    width: 100%;
    resize: vertical;
    font-family: inherit;
    font-size: 14px;
    color: var(--ink);
    background: transparent;
    border: none;
}
.modal__dialog textarea::placeholder { color: var(--ink-soft); }
.modal__dialog textarea:focus { outline: none; }

.modal__actions {
    display: flex;
    justify-content: flex-end;
    gap: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
    margin-top: 8px;
}

.action--primary {
    color: var(--accent);
    font-weight: 600;
}
.action--primary:hover { color: #fff; }

/* toast */

.toast {
    position: fixed;
    left: 50%;
    bottom: 28px;
    transform: translateX(-50%) translateY(8px);
    background: #fff;
    color: #0a0a0b;
    font-size: 12px;
    font-weight: 600;
    padding: 8px 14px;
    border-radius: 999px;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
}
.toast--visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* login */

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

.login h1 { margin-bottom: 12px; }

.login label {
    font-size: 12px;
    color: var(--ink-soft);
}

.login input {
    font-family: inherit;
    font-size: 14px;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--ink);
}
.login input:focus {
    outline: none;
    border-color: var(--accent);
}

.login button {
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    padding: 10px 12px;
    border-radius: 8px;
    border: none;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    margin-top: 4px;
}
.login button:hover { opacity: 0.9; }

.error {
    color: #ff5c5c;
    font-size: 12px;
    margin: 0;
}

@media (max-width: 640px) {
    .topbar { flex-wrap: wrap; }
}
