:root {
    color-scheme: light dark;
    --bg: #ffffff;
    --fg: #1d1d1f;
    --muted: #6b6b70;
    --line: #d9d9de;
    --field: #f5f5f7;
    --accent: #2563eb;
    --accent-fg: #ffffff;
    --notice: #e7f5ec;
    --notice-fg: #14532d;
    --error: #fdecec;
    --error-fg: #8a1c1c;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #161618;
        --fg: #ececf0;
        --muted: #9a9aa2;
        --line: #34343a;
        --field: #222226;
        --accent: #6b9bff;
        --accent-fg: #0b0b0c;
        --notice: #143321;
        --notice-fg: #b9ecc9;
        --error: #3a1818;
        --error-fg: #ffc4c4;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--fg);
    font: 16px/1.5 system-ui, -apple-system, "Noto Sans KR", sans-serif;
}

main {
    max-width: 640px;
    margin: 0 auto;
    padding: 16px;
}

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

h1 { font-size: 1.25rem; margin: 0; }

.bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.menu { position: relative; }
.menu summary {
    display: flex;
    padding: 6px;
    list-style: none;
    cursor: pointer;
    color: var(--fg);
}
.menu summary::-webkit-details-marker { display: none; }
.menu summary svg {
    width: 1.5rem;
    height: 1.5rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
}
.menu nav {
    position: absolute;
    right: 0;
    top: 100%;
    z-index: 10;
    min-width: 10rem;
    padding: 4px 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--bg);
    box-shadow: 0 4px 16px rgb(0 0 0 / 0.15);
}
.menu nav a {
    display: block;
    padding: 10px 16px;
    color: var(--fg);
    text-decoration: none;
    white-space: nowrap;
}
.menu nav a:hover { background: var(--field); }

.muted { color: var(--muted); font-size: 0.875rem; }

.notice, .error {
    padding: 10px 12px;
    border-radius: 8px;
}
.notice { background: var(--notice); color: var(--notice-fg); }
.error { background: var(--error); color: var(--error-fg); }

.form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.form label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.875rem;
    color: var(--muted);
}

.form .row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

input, textarea, button {
    font: inherit;
    color: var(--fg);
}

input, textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--field);
}

textarea { resize: vertical; }

button {
    padding: 12px;
    border: 0;
    border-radius: 8px;
    background: var(--accent);
    color: var(--accent-fg);
    font-weight: 600;
    cursor: pointer;
}

.preview img, .attachments img {
    display: block;
    width: 100%;
    border-radius: 8px;
}
.preview { display: block; margin-bottom: 16px; }

.attachments {
    list-style: none;
    padding: 0;
    margin: 0 0 16px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
}
.attachments li { overflow-wrap: anywhere; }

.filter { display: flex; gap: 12px; }

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}
.filters input, .filters button { height: 30px; }
.filters input { flex: 1 1 8rem; width: auto; min-width: 0; padding: 0 10px; }
.filters .search { flex: 3 1 12rem; }
.filters button { flex: none; padding: 0 14px; }

.delete-item { margin-top: 24px; }
.delete-item button {
    width: 100%;
    border: 1px solid var(--error-fg);
    background: transparent;
    color: var(--error-fg);
}

.items {
    list-style: none;
    padding: 0;
    margin: 0;
}
.items li {
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.items .meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    color: var(--muted);
}
.items .tag {
    padding: 0 8px;
    border: 1px solid var(--line);
    border-radius: 999px;
    text-decoration: none;
}
.items .title { color: var(--fg); font-weight: 600; text-decoration: none; }
.items .url {
    font-size: 0.875rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.items .memo { margin: 0; font-size: 0.9375rem; }
.items .delete { margin-left: auto; }
.items .delete button {
    display: flex;
    padding: 2px;
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: inherit;
}
.items .delete svg {
    width: 1em;
    height: 1em;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.items .delete button:hover { color: var(--error-fg); }
