:root {
    --bg: #2f2f2f;
    --panel: #3b3b3b;
    --panel-soft: #4a4a4a;
    --text: #f8f6f2;
    --muted: #d9d1c8;
    --accent: #fa8b3c;
    --accent-dark: #803702;
    --danger: #c43f2f;
    --success: #2e8b57;
    --border: #5a5a5a;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Barlow', sans-serif;
    color: var(--text);
    overflow-x: hidden;
    background:
        radial-gradient(circle at 12% 2%, rgba(250, 139, 60, 0.2), transparent 28%),
        radial-gradient(circle at 90% 20%, rgba(128, 55, 2, 0.3), transparent 35%),
        var(--bg);
}

h1, h2, h3, .brand-text {
    font-family: 'Sora', sans-serif;
    margin: 0;
}

.app-shell {
    width: min(100%, 980px);
    margin: 0 auto;
    min-height: 100vh;
    padding: 0.6rem;
}

.topbar {
    background: linear-gradient(95deg, var(--accent-dark), var(--accent));
    border-radius: 14px;
    padding: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0.4rem;
    z-index: 30;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    text-decoration: none;
    color: #151515;
    font-weight: 700;
}

.brand-mark {
    width: 2rem;
    height: 2rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.75);
    display: grid;
    place-items: center;
}

.menu-wrap {
    position: relative;
}

.menu-wrap summary {
    list-style: none;
}

.menu-wrap summary::-webkit-details-marker {
    display: none;
}

.menu-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 0.4rem);
    width: 210px;
    border: 1px solid var(--border);
    background: #1f1f1f;
    border-radius: 10px;
    padding: 0.6rem;
    display: grid;
    gap: 0.45rem;
}

.menu-panel a,
.menu-action {
    width: 100%;
    text-align: left;
    border: 0;
    background: var(--panel-soft);
    color: var(--text);
    text-decoration: none;
    padding: 0.52rem 0.62rem;
    border-radius: 7px;
    font: inherit;
}

.menu-action.danger {
    background: var(--danger);
}

.icon-btn {
    background: rgba(255, 255, 255, 0.7);
    border: 0;
    border-radius: 10px;
    min-width: 2.5rem;
    min-height: 2.5rem;
    display: grid;
    place-items: center;
    cursor: pointer;
}

.page {
    display: grid;
    gap: 0.6rem;
    padding-block: 0.6rem;
}

.panel {
    border: 1px solid rgba(250, 139, 60, 0.35);
    background: var(--panel);
    border-radius: 14px;
    padding: 0.88rem;
    display: grid;
    gap: 0.68rem;
}

.panel.narrow {
    max-width: 580px;
    margin-inline: auto;
}

.stack {
    display: grid;
    gap: 0.64rem;
}

.inline-form {
    display: grid;
    gap: 0.5rem;
}

label {
    display: grid;
    gap: 0.25rem;
    font-weight: 600;
}

input,
select,
textarea,
button {
    font: inherit;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #f5f5f5;
    color: #181818;
    padding: 0.55rem 0.62rem;
}

textarea {
    min-height: 100px;
    resize: vertical;
}

.btn {
    text-decoration: none;
    border: 0;
    border-radius: 8px;
    background: var(--panel-soft);
    color: var(--text);
    padding: 0.64rem 0.78rem;
    min-height: 2.6rem;
    display: inline-grid;
    place-items: center;
    cursor: pointer;
}

.btn.primary {
    background: linear-gradient(95deg, var(--accent-dark), var(--accent));
    color: #1b1b1b;
    font-weight: 700;
}

.btn.ghost {
    border: 1px solid var(--accent);
    background: transparent;
}

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

.btn.mini {
    min-height: 2rem;
    padding: 0.3rem 0.5rem;
}

.btn.icon {
    width: 2.5rem;
    padding: 0;
}

.btn.icon img {
    width: 1.25rem;
    height: 1.25rem;
}

.heading-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
}

.button-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.card-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.45rem;
}

.card-link,
.card-inline {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.6rem;
    color: inherit;
    text-decoration: none;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: #2f2f2f;
    padding: 0.56rem;
}

.inline-actions {
    display: flex;
    gap: 0.35rem;
}

.history-card {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #2f2f2f;
    padding: 0.56rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.65rem;
    flex-wrap: wrap;
}

.history-card-main {
    display: grid;
    gap: 0.25rem;
}

.notice {
    border-radius: 8px;
    padding: 0.5rem;
    background: #4c4c4c;
}

.notice.success {
    background: color-mix(in srgb, var(--success) 35%, #222);
}

.notice.danger {
    background: color-mix(in srgb, var(--danger) 35%, #222);
}

.danger-zone {
    border-color: color-mix(in srgb, var(--danger) 65%, var(--border));
}

.muted {
    color: var(--muted);
}

.streak-compact {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem 0.8rem;
    align-items: baseline;
    margin-top: -0.15rem;
}

.streak-current {
    font-size: 1.05rem;
    font-weight: 700;
}

.streak-note {
    margin-top: -0.2rem;
}

.routine-item {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #2f2f2f;
    padding: 0.6rem;
    display: grid;
    gap: 0.4rem;
}

.log-accordion {
    width: 100%;
}

.log-summary {
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.6rem;
    list-style: none;
}

.log-summary::-webkit-details-marker {
    display: none;
}

.log-summary-hint {
    transition: opacity 0.16s ease;
}

.log-accordion[open] .log-summary-hint {
    display: none;
}

.history-type {
    display: inline-block;
    padding: 0.12rem 0.44rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--accent) 25%, #222);
    border: 1px solid color-mix(in srgb, var(--accent) 60%, var(--border));
    font-size: 0.84rem;
    font-weight: 700;
}

.history-filters {
    flex-wrap: wrap;
}

.public-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.22rem;
    font-size: 0.82rem;
    color: var(--muted);
    font-weight: 600;
    margin-left: 0.2rem;
}

.public-tag img {
    width: 0.86rem;
    height: 0.86rem;
}

.prefill-hint {
    border: 1px dashed color-mix(in srgb, var(--accent) 65%, var(--border));
    border-radius: 8px;
    padding: 0.42rem 0.5rem;
}

.routine-tools {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.check-row input {
    width: auto;
}

.media-preview {
    width: min(100%, 360px);
    border-radius: 10px;
    border: 1px solid var(--border);
}

.consistency-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0.35rem;
}

.consistency-item {
    background: #2f2f2f;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.36rem;
    display: grid;
    place-items: center;
    gap: 0.2rem;
}

.consistency-item.done {
    border-color: var(--success);
    background: #264936;
}

.table-wrap {
    overflow-x: auto;
}

.reports-table {
    width: 100%;
    table-layout: fixed;
}

.reports-table td,
.reports-table th {
    min-width: 0;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    border: 1px solid var(--border);
    padding: 0.35rem;
    text-align: left;
}

.toast {
    position: fixed;
    left: 50%;
    bottom: 0.8rem;
    transform: translateX(-50%) translateY(calc(100% + 1.2rem));
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    min-width: min(90vw, 420px);
    border-radius: 10px;
    padding: 0.65rem;
    background: var(--accent);
    color: #1a1a1a;
    font-weight: 700;
    transition: transform 0.24s ease;
    z-index: 50;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    visibility: visible;
}

.report-canvas {
    display: block;
    width: 100% !important;
    max-width: 100%;
}

@media (min-width: 700px) {
    .inline-form {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        align-items: end;
    }

    .inline-form.two-col {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .inline-form .btn {
        align-self: end;
    }

    .page {
        gap: 0.75rem;
    }
}

@media (max-width: 699px) {
    .reports-table thead {
        display: none;
    }

    .reports-table,
    .reports-table tbody,
    .reports-table tr,
    .reports-table td {
        display: block;
        width: 100%;
    }

    .reports-table tr {
        border: 1px solid var(--border);
        border-radius: 10px;
        background: #2f2f2f;
        padding: 0.45rem;
        margin-bottom: 0.55rem;
    }

    .reports-table td {
        border: 0;
        border-bottom: 1px solid color-mix(in srgb, var(--border) 45%, transparent);
        padding: 0.42rem 0;
        line-height: 1.3;
    }

    .reports-table td:last-child {
        border-bottom: 0;
    }

    .reports-table td::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 0.15rem;
        font-weight: 700;
        color: var(--muted);
    }

    .table-wrap {
        max-width: 100%;
        overflow-x: hidden;
    }

    .button-grid {
        grid-template-columns: 1fr;
    }
}
