:root {
    --ink: #1c1917;
    --muted: #78716c;
    --line: #e7e5e4;
    --paper: #fafaf9;
    --card: #ffffff;
    --accent: #0f766e;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font: 16px/1.45 "Iowan Old Style", Palatino, "Palatino Linotype", serif;
}

.top {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--line);
    background: var(--card);
}

.brand {
    color: var(--ink);
    text-decoration: none;
    font-weight: 700;
    letter-spacing: 0.02em;
}

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

main { max-width: 1120px; margin: 0 auto; padding: 1.5rem; }

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

input[type="search"], select, input[type="text"] {
    font: inherit;
    padding: 0.5rem 0.7rem;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--card);
    min-width: 220px;
}

button, .btn {
    font: inherit;
    padding: 0.5rem 0.9rem;
    border: 0;
    border-radius: 6px;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    text-decoration: none;
}

button:disabled {
    opacity: 0.6;
    cursor: wait;
}

.btn-secondary {
    background: #fff;
    color: var(--accent);
    border: 1px solid var(--accent);
}

.research {
    margin-top: 1.25rem;
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--paper);
}

.research h3 {
    margin: 0 0 0.5rem;
    font-size: 1rem;
}

.research-status {
    margin: 0 0 0.75rem;
}

.problem-list {
    list-style: none;
    padding: 0;
    margin: 0 0 0.75rem;
    display: grid;
    gap: 0.65rem;
}

.problem-item {
    padding: 0.65rem 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #fff;
}

.problem-item p {
    margin: 0.35rem 0 0;
}

.problem-head {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.5rem;
    align-items: center;
}

.problem-badge {
    display: inline-block;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.12rem 0.4rem;
    border-radius: 999px;
    background: #ecfdf5;
    color: #047857;
}

.problem-badge-muted {
    background: #f5f5f4;
    color: var(--muted);
}

.problem-severity-warning {
    border-color: #fde68a;
    background: #fffbeb;
}

.problem-severity-warning .problem-badge:first-child {
    background: #fef3c7;
    color: #b45309;
}

.problem-severity-critical {
    border-color: #fecaca;
    background: #fef2f2;
}

.problem-severity-critical .problem-badge:first-child {
    background: #fee2e2;
    color: #b91c1c;
}

.problem-quote {
    margin: 0.45rem 0 0;
    padding: 0.45rem 0.65rem;
    border-left: 3px solid var(--line);
    color: var(--muted);
    font-size: 0.92rem;
}

.living-surface-form {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.living-surface-form input[type="number"] {
    width: 7rem;
}

.list-add-form {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.list-add-form input[type="text"] {
    flex: 1 1 180px;
    min-width: 180px;
}

.list-or {
    font-size: 0.9rem;
}

.list-index {
    list-style: none;
    padding: 0;
    margin: 1rem 0 0;
}

.list-index a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

h1 {
    margin: 0 0 0.25rem;
    font-size: 1.5rem;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.card-wrap {
    position: relative;
}

.card-list-btn,
.card-remove-btn {
    position: absolute;
    top: 0.6rem;
    right: 0.6rem;
    z-index: 2;
    font: inherit;
    font-size: 0.82rem;
    padding: 0.3rem 0.55rem;
    border-radius: 6px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.95);
    color: var(--accent);
    cursor: pointer;
}

.card-remove-btn {
    color: #b91c1c;
    border-color: #fecaca;
}

.card-list-btn:hover,
.card-remove-btn:hover {
    background: #fff;
}

.list-modal {
    position: fixed;
    inset: 0;
    background: rgba(28, 25, 23, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 20;
}

.list-modal[hidden] {
    display: none;
}

.list-modal-box {
    width: min(100%, 480px);
    background: var(--card);
    border-radius: 10px;
    padding: 1rem 1.1rem 1.2rem;
    border: 1px solid var(--line);
}

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

.list-modal-head h3 {
    margin: 0;
    font-size: 1rem;
}

.list-modal-close {
    font: inherit;
    font-size: 1.4rem;
    line-height: 1;
    border: 0;
    background: transparent;
    cursor: pointer;
    color: var(--muted);
}

.list-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 0.75rem;
}

.list-rename-form {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    flex: 1 1 280px;
}

.btn-small {
    padding: 0.35rem 0.65rem;
    font-size: 0.9rem;
}

.btn-danger {
    background: #fff;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.list-index li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--line);
}

.list-index-main {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.list-index-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
}

.card img, .hero img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    background: #eceae8;
}

.hero img { height: 320px; border-radius: 10px; }

.pad { padding: 0.9rem 1rem 1.1rem; }

.price { font-size: 1.15rem; font-weight: 700; }
.meta { color: var(--muted); font-size: 0.92rem; }
.badge {
    display: inline-block;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--accent);
}

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

.detail { display: grid; gap: 1.25rem; }
@media (min-width: 840px) {
    .detail { grid-template-columns: 1.2fr 0.8fr; }
}

dl { display: grid; grid-template-columns: 9rem 1fr; gap: 0.35rem 0.75rem; }
dt { color: var(--muted); }
dd { margin: 0; }

.password { white-space: pre-wrap; }
.links a { color: var(--accent); }
.links a.btn { color: #fff; }

.auth-card {
    max-width: 28rem;
    margin: 2rem auto;
    padding: 1.5rem;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.auth-card h1 {
    margin: 0 0 1rem;
    font-size: 1.5rem;
}

.auth-form,
.auth-setup {
    display: grid;
    gap: 0.85rem;
}

.auth-form label,
.auth-setup label {
    display: grid;
    gap: 0.35rem;
}

.auth-form input,
.auth-setup input {
    min-width: 0;
    width: 100%;
}

.auth-note {
    color: var(--muted);
    margin: 0 0 1rem;
}

.auth-code {
    padding: 0.75rem 1rem;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 6px;
    overflow-x: auto;
    font: 0.9rem/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.auth-divider {
    text-align: center;
    color: var(--muted);
    margin: 1rem 0;
}

.btn-wide {
    width: 100%;
}

.auth-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.auth-error {
    margin-top: 1rem;
    color: #b91c1c;
}

.hidden {
    display: none !important;
}
