:root {
    --bg: #f6f2e8;
    --card: rgba(255, 252, 247, 0.96);
    --line: rgba(35, 41, 48, 0.12);
    --text: #232930;
    --muted: #68717b;
    --accent: #145e7a;
    --accent-strong: #0d465c;
    --accent-soft: rgba(20, 94, 122, 0.12);
    --warn: #8b4a18;
    --warn-soft: rgba(139, 74, 24, 0.12);
    --error: #9d3042;
    --error-soft: rgba(157, 48, 66, 0.12);
    --shadow: 0 18px 38px rgba(35, 41, 48, 0.08);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    color: var(--text);
    font-family: "Hiragino Sans", "Yu Gothic", "Noto Sans JP", sans-serif;
    background:
        radial-gradient(circle at top left, rgba(20, 94, 122, 0.12), transparent 30%),
        linear-gradient(180deg, #faf6ef 0%, var(--bg) 100%);
}

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

button,
select,
input[type="range"],
input[type="checkbox"] {
    cursor: pointer;
}

.page {
    width: min(760px, calc(100% - 24px));
    margin: 0 auto;
    padding: 18px 0 28px;
}

.hero {
    margin-bottom: 10px;
}

h1,
h2 {
    margin: 0;
}

h1 {
    margin-top: 0;
    font-size: clamp(1.8rem, 4vw, 2.4rem);
    line-height: 1.05;
}

.panel {
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--card);
    box-shadow: var(--shadow);
    padding: 16px;
}

.panel + .panel {
    margin-top: 12px;
}

.status-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 12px;
    align-items: center;
    font-size: 0.95rem;
}

.meta-hidden {
    display: none;
}

.title-row {
    margin-top: 12px;
}

.title-row input {
    width: 100%;
    min-height: 46px;
    padding: 11px 13px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: white;
    color: var(--text);
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent-strong);
    font-weight: 600;
}

.pill::before {
    content: "";
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: currentColor;
}

.pill.ready {
    background: var(--accent-soft);
    color: var(--accent-strong);
}

.pill.active {
    background: rgba(20, 94, 122, 0.18);
    color: var(--accent-strong);
}

.pill.warn {
    background: var(--warn-soft);
    color: var(--warn);
}

.pill.error {
    background: var(--error-soft);
    color: var(--error);
}

.caption-stage {
    position: relative;
    min-height: 300px;
    margin-top: 14px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: white;
}

.caption-frame {
    display: grid;
    min-height: 300px;
    padding: 18px;
    align-items: center;
}

.caption-text {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--text);
    font-size: 38px;
    line-height: 1.45;
    font-weight: 700;
    text-align: center;
}

.caption-stage:fullscreen,
.caption-stage:-webkit-full-screen {
    border-radius: 0;
}

.message {
    margin: 10px 0 0;
    color: var(--muted);
    line-height: 1.5;
    min-height: 1.5em;
}

.action-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-top: 14px;
}

.action-row button {
    min-height: 50px;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: white;
    color: var(--text);
    transition: transform 120ms ease, box-shadow 120ms ease;
}

.action-row button:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(35, 41, 48, 0.1);
}

.action-row button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.action-row .primary {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
    color: white;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.field {
    display: grid;
    gap: 8px;
    align-content: start;
}

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

.field select,
.field input[type="range"] {
    width: 100%;
}

.field select,
.log-area,
.debug textarea {
    border-radius: 12px;
    border: 1px solid var(--line);
    background: white;
    color: var(--text);
}

.field select {
    min-height: 46px;
    padding: 10px 12px;
}

.checks {
    align-self: end;
    gap: 12px;
}

.checks label {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
}

.action-field {
    align-self: end;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.action-field button {
    min-height: 46px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: white;
}

.log-area {
    width: 100%;
    min-height: 200px;
    margin-top: 12px;
    padding: 14px;
    resize: vertical;
    line-height: 1.6;
}

.details-panel summary {
    cursor: pointer;
    font-weight: 600;
}

.details-panel[open] summary {
    margin-bottom: 12px;
}

.debug summary {
    font-weight: 600;
}

.debug textarea {
    width: 100%;
    min-height: 160px;
    margin-top: 12px;
    padding: 10px;
    font-size: 12px;
    font-family: Monaco, "SFMono-Regular", monospace;
}

@media (max-width: 920px) {
    .action-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .page {
        width: min(100%, calc(100% - 18px));
        padding: 14px 0 24px;
    }

    .settings-grid,
    .action-row {
        grid-template-columns: 1fr;
    }

    .action-field {
        grid-template-columns: 1fr;
    }

    .caption-stage,
    .caption-frame {
        min-height: 240px;
    }

    .caption-text {
        font-size: 30px;
    }
}
