:root {
    --bg: #f4f6f8;
    --surface: #ffffff;
    --border: #d9dee5;
    --text: #17202a;
    --muted: #64707d;
    --primary: #0f766e;
    --primary-dark: #0b5c56;
    --primary-soft: #e0f2f0;
    --danger: #b42318;
    --danger-soft: #fde8e6;
    --warning-soft: #fff4d6;
    --radius: 12px;
    --touch: 56px;
    --shadow: 0 1px 3px rgba(23, 32, 42, 0.08), 0 6px 18px rgba(23, 32, 42, 0.06);
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    min-height: 100dvh;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 17px;
    line-height: 1.45;
}

h1,
h2,
p {
    margin: 0;
}

h1 {
    font-size: 1.5rem;
}

h2 {
    font-size: 1.15rem;
}

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

code {
    font-size: 0.85em;
    background: var(--bg);
    padding: 2px 6px;
    border-radius: 6px;
}

[hidden] {
    display: none !important;
}

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

.nowrap {
    white-space: nowrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: var(--touch);
    padding: 0 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    touch-action: manipulation;
    user-select: none;
}

.btn:active {
    transform: translateY(1px);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn:focus-visible,
.input:focus-visible,
.numpad-key:focus-visible,
.user-tile:focus-visible {
    outline: 3px solid rgba(15, 118, 110, 0.35);
    outline-offset: 2px;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
}

.btn-primary:active {
    background: var(--primary-dark);
}

.btn-danger {
    background: var(--surface);
    border-color: var(--danger);
    color: var(--danger);
}

.btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--muted);
}

.btn-block {
    width: 100%;
}

.form {
    display: grid;
    gap: 16px;
}

.field {
    display: grid;
    gap: 6px;
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--muted);
}

.input {
    width: 100%;
    min-height: var(--touch);
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-weight: 400;
}

textarea.input {
    resize: vertical;
}

.input.is-invalid {
    border-color: var(--danger);
    background: var(--danger-soft);
}

.form-error {
    padding: 12px 14px;
    border-radius: var(--radius);
    background: var(--danger-soft);
    color: var(--danger);
    font-weight: 600;
}

.checks {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 0;
    border: 0;
}

.checks legend {
    padding: 0 0 8px;
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--muted);
}

.check {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    min-height: var(--touch);
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    cursor: pointer;
}

.check input {
    flex: none;
    width: 24px;
    height: 24px;
    margin: 2px 0 0;
    accent-color: var(--primary);
}

.check.is-disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.check-text {
    display: grid;
    gap: 2px;
}

.check-title {
    font-weight: 600;
}

.check-hint {
    color: var(--muted);
    font-size: 0.85rem;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary-dark);
    font-size: 0.82rem;
    font-weight: 600;
}

.badge-owner {
    background: var(--warning-soft);
    color: #7a5200;
}

.badge-muted {
    background: var(--bg);
    color: var(--muted);
}

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

.toast-stack {
    position: fixed;
    top: calc(16px + env(safe-area-inset-top, 0px));
    left: 50%;
    z-index: 1000;
    display: grid;
    gap: 8px;
    width: max-content;
    max-width: min(420px, calc(100vw - 32px));
    transform: translateX(-50%);
    pointer-events: none;
}

.toast {
    padding: 14px 18px;
    border-radius: var(--radius);
    background: var(--text);
    color: #ffffff;
    font-weight: 600;
    box-shadow: var(--shadow);
}

.toast-error {
    background: var(--danger);
}

.modal {
    width: min(560px, calc(100vw - 24px));
    max-height: calc(100dvh - 24px);
    padding: 0;
    border: 0;
    border-radius: 16px;
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow);
}

.modal::backdrop {
    background: rgba(23, 32, 42, 0.55);
}

.modal-head {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 12px 12px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.modal-body {
    padding: 20px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.numpad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.numpad-key {
    min-height: 68px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 1.6rem;
    font-weight: 600;
    cursor: pointer;
    touch-action: manipulation;
    user-select: none;
}

.numpad-key:active {
    background: var(--primary-soft);
}

.numpad-enter {
    background: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
}

.numpad-enter:active {
    background: var(--primary-dark);
}
