/* ── Base ─────────────────────────────────────── */
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Hiragino Sans", "Noto Sans JP", sans-serif;
    background: #f5f7fa;
    color: #1a1a2e;
    line-height: 1.5;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── Header ──────────────────────────────────── */
header {
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    color: #fff;
    padding: 16px 32px;
    position: relative;
    flex-shrink: 0;
}
header h1 { font-size: 1.4rem; font-weight: 700; }
header .subtitle { font-size: 0.82rem; opacity: 0.7; margin-top: 2px; }
.header-links {
    position: absolute; right: 32px; top: 50%; transform: translateY(-50%);
    display: flex; gap: 16px;
}
.header-link {
    color: #9bb5e8; text-decoration: none; font-size: 0.85rem;
}
.header-link:hover { color: #fff; }

/* ── Layout ──────────────────────────────────── */
.layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────── */
.sidebar {
    width: 280px;
    background: #fff;
    border-right: 1px solid #e0e4ec;
    overflow-y: auto;
    flex-shrink: 0;
}
.sidebar-title {
    padding: 16px 20px 8px;
    font-size: 0.85rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.site-list {
    list-style: none;
    padding: 0;
}
.site-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    cursor: pointer;
    border-bottom: 1px solid #f0f2f5;
    transition: background 0.15s;
}
.site-item:hover { background: #f5f7fa; }
.site-item.active {
    background: #eef2ff;
    border-left: 3px solid #4361ee;
    padding-left: 17px;
}
.site-name {
    flex: 1;
    font-weight: 500;
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.site-id {
    font-size: 0.75rem;
    color: #aaa;
    font-family: monospace;
}
.badge {
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 8px;
    font-weight: 600;
    text-transform: uppercase;
}
.badge-en { background: #dbeafe; color: #1e40af; }
.badge-ja { background: #fce7f3; color: #9d174d; }

.loading {
    padding: 20px;
    text-align: center;
    color: #999;
    font-size: 0.9rem;
}

/* ── Editor ──────────────────────────────────── */
.editor {
    flex: 1;
    overflow-y: auto;
    padding: 24px 32px;
}
.placeholder {
    text-align: center;
    padding: 80px 20px;
    color: #999;
}
.placeholder-icon {
    font-size: 4rem;
    margin-bottom: 16px;
    opacity: 0.3;
}
.placeholder-sub {
    font-size: 0.85rem;
    color: #bbb;
    margin-top: 4px;
}
.hidden { display: none !important; }

/* ── Editor Header ───────────────────────────── */
.editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid #e0e4ec;
    position: sticky;
    top: -24px;
    background: #f5f7fa;
    z-index: 10;
    padding-top: 8px;
}
.editor-header h2 {
    font-size: 1.2rem;
    color: #1a1a2e;
}
.editor-actions {
    display: flex;
    gap: 8px;
}
.btn {
    padding: 8px 20px;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.15s;
}
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
.btn-primary {
    background: #4361ee;
    color: #fff;
}
.btn-primary:hover:not(:disabled) { background: #3651d4; }
.btn-secondary {
    background: #e0e4ec;
    color: #333;
}
.btn-secondary:hover:not(:disabled) { background: #d0d4dc; }

/* ── Field Groups ────────────────────────────── */
.field-group {
    background: #fff;
    border-radius: 10px;
    padding: 20px 24px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.group-title {
    font-size: 0.95rem;
    color: #1a1a2e;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.group-icon {
    font-size: 1.1rem;
}
.field-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
@media (max-width: 900px) {
    .field-grid { grid-template-columns: 1fr; }
}

/* ── Field ───────────────────────────────────── */
.field-wrapper {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.field-wrapper:has(textarea) {
    grid-column: 1 / -1;
}
.field-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #555;
}
.field-input {
    padding: 8px 12px;
    border: 1px solid #d0d4dc;
    border-radius: 6px;
    font-size: 0.88rem;
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
    width: 100%;
}
.field-input:focus {
    outline: none;
    border-color: #4361ee;
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1);
}
.field-input.readonly {
    background: #f5f7fa;
    color: #888;
    cursor: not-allowed;
}
textarea.field-input {
    font-family: "SF Mono", "Menlo", "Consolas", monospace;
    font-size: 0.82rem;
    resize: vertical;
    min-height: 80px;
}
.json-input {
    font-family: "SF Mono", "Menlo", "Consolas", monospace;
    font-size: 0.82rem;
}
select.field-input {
    cursor: pointer;
    appearance: auto;
}
input[type="number"].field-input {
    max-width: 150px;
}
.checkbox-field {
    flex-direction: row;
    align-items: center;
    gap: 8px;
}
.checkbox-field .field-input {
    width: auto;
}
.field-help {
    font-size: 0.72rem;
    color: #aaa;
}

/* ── Toast ───────────────────────────────────── */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    color: #fff;
    z-index: 1000;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: none;
}
.toast.show {
    opacity: 1;
    transform: translateY(0);
}
.toast-success { background: #059669; }
.toast-error { background: #dc2626; }
.toast-info { background: #2563eb; }
