/* ボタン、見出し、入力、通知、ダイアログなど画面横断の部品を定義する。 */
.button {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.62rem 1rem;
    border: 1px solid transparent;
    border-radius: 999px;
    font-weight: 750;
    line-height: 1.2;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.button:hover:not(:disabled) { transform: translateY(-1px); }

.button:disabled {
    border-color: var(--color-border);
    color: #939cab;
    background: #eef0f3;
    cursor: not-allowed;
    transform: none;
}

.button--primary {
    color: #fff;
    background: var(--color-primary-strong);
    box-shadow: 0 6px 16px rgba(159, 41, 8, 0.2);
}

.button--primary:hover:not(:disabled) { background: #7f2005; }

.button--secondary {
    border-color: #c8d0dc;
    color: var(--color-ink);
    background: #fff;
}

.button--secondary:hover:not(:disabled) {
    border-color: var(--color-primary);
    background: var(--color-primary-soft);
}

.button--ghost { color: var(--color-ink); background: transparent; }
.button--ghost:hover { color: var(--color-primary-strong); background: var(--color-primary-soft); }

.page-heading {
    display: flex;
    align-items: stretch;
    gap: 1rem;
    margin-bottom: 1.75rem;
}

.page-heading__mark {
    width: 8px;
    flex: 0 0 8px;
    border-radius: 999px;
    background: linear-gradient(var(--color-primary), var(--color-accent));
}

.page-heading h1 {
    margin: 0;
    font-size: clamp(1.75rem, 4vw, 2.5rem);
    line-height: 1.25;
}

.page-heading p { margin: 0.35rem 0 0; color: var(--color-muted); }

.section-heading {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 1.25rem;
}

.section-heading > span { color: var(--color-primary); font-size: 1.4rem; }
.section-heading h2 { margin: 0; font-size: clamp(1.35rem, 3vw, 1.75rem); }

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

.toolbar--start { justify-content: flex-start; }
.toolbar--between { justify-content: space-between; }
.toolbar__group { display: flex; flex-wrap: wrap; gap: 0.75rem; }

.tool-panel {
    padding: clamp(1rem, 3vw, 2rem);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: #fff;
    box-shadow: var(--shadow-sm);
}

.field-label {
    display: inline-block;
    margin-bottom: 0.45rem;
    font-weight: 750;
}

input[type="text"],
input[type="number"],
textarea {
    border: 1px solid #bfc8d5;
    border-radius: var(--radius-sm);
    background: #fff;
}

input[type="text"],
input[type="number"] {
    min-height: 44px;
    padding: 0.55rem 0.75rem;
}

input[type="color"] {
    width: 56px;
    height: 44px;
    padding: 3px;
    border: 1px solid #bfc8d5;
    border-radius: var(--radius-sm);
    background: #fff;
    cursor: pointer;
}

.field-help {
    margin: 0.6rem 0 0;
    color: var(--color-muted);
    font-size: 0.88rem;
}

.notice {
    margin: 1.25rem 0;
    padding: 1rem 1.25rem;
    border: 1px solid #efcfaa;
    border-radius: var(--radius-sm);
    color: #6f4c20;
    background: #fff8e8;
}

.notice p { margin: 0; }

.operation-status {
    min-height: 1.7em;
    margin-top: 1rem;
    color: var(--color-success);
    font-weight: 650;
}

.operation-status--error { color: var(--color-danger); }

.error-state,
.fatal-error,
.page-loading {
    padding: 3rem 1.25rem;
    border: 1px dashed #c8ced7;
    border-radius: var(--radius-md);
    color: var(--color-muted);
    background: #fff;
    text-align: center;
}

.error-state h1,
.fatal-error h1 { margin-top: 0; color: var(--color-ink); }

.page-loading {
    min-height: 260px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.section-divider {
    height: 1px;
    margin: clamp(2.5rem, 6vw, 5rem) 0;
    background: linear-gradient(90deg, transparent, var(--color-border), transparent);
}

.content-dialog {
    width: min(860px, calc(100vw - 2rem));
    max-height: min(86vh, 900px);
    padding: 0;
    border: 0;
    border-radius: var(--radius-md);
    color: var(--color-ink);
    background: transparent;
    box-shadow: var(--shadow-md);
}

.content-dialog::backdrop {
    background: rgba(18, 29, 43, 0.66);
    backdrop-filter: blur(3px);
}

.content-dialog__surface {
    max-height: min(86vh, 900px);
    display: grid;
    grid-template-rows: auto 1fr;
    overflow: hidden;
    background: #fff;
}

.content-dialog__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--color-border);
}

.content-dialog__header h2 { margin: 0; }

.content-dialog__actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.content-dialog__actions > a {
    padding: 0.45rem 0.6rem;
    border-radius: var(--radius-sm);
    color: var(--color-muted);
    font-size: 0.86rem;
    text-underline-offset: 0.2em;
}

.content-dialog__actions > a:hover {
    color: var(--color-primary-strong);
    background: var(--color-primary-soft);
}

.content-dialog__frame {
    width: 100%;
    height: min(74vh, 780px);
    display: block;
    border: 0;
    background: #fff;
}

.icon-button {
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    color: var(--color-ink);
    background: var(--color-surface-alt);
    cursor: pointer;
    font-size: 1.75rem;
    line-height: 1;
}

.icon-button:hover { background: var(--color-primary-soft); }

.toast {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 1200;
    max-width: min(420px, calc(100vw - 2rem));
    padding: 0.9rem 1.15rem;
    border-radius: var(--radius-sm);
    color: #fff;
    background: var(--color-ink);
    box-shadow: var(--shadow-md);
}

@media (max-width: 640px) {
    .toolbar--between { align-items: stretch; flex-direction: column; }
    .toolbar__group,
    .toolbar--between > .button { width: 100%; }
    .toolbar__group .button { flex: 1 1 auto; }
    .content-dialog { width: calc(100vw - 1rem); max-height: calc(100vh - 1rem); }
    .content-dialog__surface { max-height: calc(100vh - 1rem); }
    .content-dialog__header { padding: 0.65rem 0.75rem; }
    .content-dialog__header h2 { font-size: 1.05rem; }
    .content-dialog__actions { gap: 0.2rem; }
    .content-dialog__actions > a { padding-inline: 0.35rem; font-size: 0.76rem; }
    .content-dialog__frame { height: calc(100vh - 4.75rem); }
}
