/* ============================================
   Portfolio Editor — Styles
   ============================================ */

:root {
    --font: -apple-system, BlinkMacSystemFont, 'Inter', 'Noto Sans JP', sans-serif;
    --bg: #1a1a1a;
    --bg-surface: #242424;
    --bg-surface-hover: #2e2e2e;
    --bg-input: #1e1e1e;
    --border: #333;
    --border-focus: #555;
    --text: #e5e5e5;
    --text-secondary: #999;
    --text-muted: #666;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --success: #22c55e;
    --topbar-h: 52px;
    --sidebar-w: 200px;
    --radius: 8px;
    --radius-lg: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

/* --- Login --- */
.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: #000;
}

.login-card {
    text-align: center;
    padding: 48px;
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    width: 360px;
}

.login-icon {
    font-size: 40px;
    margin-bottom: 16px;
}

.login-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 6px;
}

.login-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 28px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.login-input {
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 14px;
    font-family: var(--font);
    outline: none;
    text-align: center;
    transition: border-color 0.2s;
}

.login-input:focus {
    border-color: var(--accent);
}

.login-btn {
    padding: 12px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: background 0.2s;
}

.login-btn:hover {
    background: var(--accent-hover);
}

.login-error {
    font-size: 13px;
    color: var(--danger);
    min-height: 20px;
}

/* --- Top Bar --- */
.topbar {
    height: var(--topbar-h);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 50;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.topbar-logo {
    font-size: 14px;
    font-weight: 600;
}

.topbar-center {
    flex: 1;
    text-align: center;
}

.save-status {
    font-size: 12px;
    color: var(--text-muted);
}

.save-status.unsaved {
    color: #f59e0b;
}

.save-status.saving {
    color: var(--accent);
}

.save-status.saved {
    color: var(--success);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.topbar-btn {
    padding: 6px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    font-family: var(--font);
    cursor: pointer;
    border: none;
    transition: all 0.15s;
}

.topbar-btn--primary {
    background: var(--accent);
    color: #fff;
}

.topbar-btn--primary:hover {
    background: var(--accent-hover);
}

.topbar-btn--secondary {
    background: var(--bg);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.topbar-btn--secondary:hover {
    border-color: var(--border-focus);
    color: var(--text);
}

.topbar-btn--ghost {
    background: transparent;
    color: var(--text-muted);
    padding: 6px 10px;
    font-size: 16px;
}

.topbar-btn--ghost:hover {
    color: var(--text);
}

/* --- Editor Body --- */
.editor-body {
    display: flex;
    margin-top: var(--topbar-h);
    height: calc(100vh - var(--topbar-h));
}

/* --- Sidebar --- */
.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    padding: 12px 8px;
    gap: 2px;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    font-family: var(--font);
    cursor: pointer;
    text-align: left;
    transition: all 0.15s;
}

.sidebar-item:hover {
    background: var(--bg-surface-hover);
    color: var(--text);
}

.sidebar-item.active {
    background: rgba(59, 130, 246, 0.12);
    color: var(--accent);
}

.sidebar-icon {
    font-size: 16px;
    width: 22px;
    text-align: center;
}

/* --- Sidebar Section Management --- */
.sidebar-section-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 8px 12px 4px;
}

.sidebar-row {
    display: flex;
    align-items: center;
    gap: 4px;
}

.sidebar-row .sidebar-item {
    flex: 1;
    min-width: 0;
}

.sidebar-row.disabled .sidebar-item {
    opacity: 0.4;
}

.sidebar-row.drag-over {
    border-top: 2px solid var(--accent);
}

/* --- Toggle Switch --- */
.toggle {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
    flex-shrink: 0;
    cursor: pointer;
    margin-right: 6px;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: #444;
    border-radius: 20px;
    transition: background 0.25s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.25s;
}

.toggle input:checked+.toggle-slider {
    background: var(--success);
}

.toggle input:checked+.toggle-slider::before {
    transform: translateX(16px);
}

/* --- Main Editor Area --- */
.editor-main {
    flex: 1;
    overflow-y: auto;
    padding: 32px 40px;
}

.section-editor {
    max-width: 760px;
}

.section-header {
    margin-bottom: 28px;
}

.section-header h2 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 4px;
}

.section-header p {
    font-size: 13px;
    color: var(--text-muted);
}

.section-hidden-notice {
    padding: 10px 14px;
    margin-bottom: 20px;
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.25);
    border-radius: var(--radius);
    font-size: 13px;
    color: #f59e0b;
    line-height: 1.5;
}

/* --- Form Elements --- */
.field {
    margin-bottom: 20px;
}

.field-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.field-input,
.field-textarea,
.field-select {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 14px;
    font-family: var(--font);
    outline: none;
    transition: border-color 0.2s;
}

.field-input:focus,
.field-textarea:focus {
    border-color: var(--accent);
}

.field-textarea {
    resize: vertical;
    min-height: 80px;
    line-height: 1.6;
}

.field-input::placeholder,
.field-textarea::placeholder {
    color: var(--text-muted);
}

.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.field-hint {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* --- Item Cards (Works, Videos, Docs, Skills) --- */
.item-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.item-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: border-color 0.2s;
}

.item-card:hover {
    border-color: var(--border-focus);
}

.item-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    user-select: none;
}

.item-card-header:hover {
    background: rgba(255, 255, 255, 0.04);
}

.item-card-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 500;
}

.item-card-drag {
    color: var(--text-muted);
    cursor: grab;
    font-size: 14px;
    padding: 2px 4px;
}

.item-card-actions {
    display: flex;
    gap: 4px;
}

.item-card-action {
    padding: 4px 8px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 14px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.15s;
}

.item-card-action:hover {
    background: var(--bg-surface-hover);
    color: var(--text);
}

.item-card-action--delete:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

.item-card-body {
    padding: 16px;
    display: none;
}

.item-card.open .item-card-body {
    display: block;
}

.item-card-chevron {
    font-size: 12px;
    color: var(--text-muted);
    transition: transform 0.2s;
}

.item-card.open .item-card-chevron {
    transform: rotate(180deg);
}

/* --- Add Button --- */
.add-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 12px;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    background: transparent;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.15s;
}

.add-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(59, 130, 246, 0.05);
}

/* --- Checkbox --- */
.field-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
}

.field-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
}

.field-checkbox label {
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
}

/* --- Skills item inline --- */
.skill-items-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 8px;
}

.skill-item-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.skill-item-row .field-input {
    flex: 1;
}

.skill-item-remove {
    padding: 6px 8px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 4px;
    font-size: 14px;
    transition: all 0.15s;
}

.skill-item-remove:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

.add-skill-btn {
    padding: 6px 12px;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    background: transparent;
    color: var(--text-muted);
    font-size: 12px;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.15s;
}

.add-skill-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* --- Toast --- */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 12px 20px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    color: #fff;
    z-index: 1000;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast--success {
    background: var(--success);
}

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

.toast--info {
    background: var(--accent);
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .sidebar {
        width: 60px;
    }

    .sidebar-label {
        display: none;
    }

    .sidebar-section-label {
        display: none;
    }

    .sidebar-row {
        flex-direction: column;
        gap: 2px;
    }

    .sidebar-row .toggle {
        display: none;
    }

    .sidebar-item {
        justify-content: center;
        padding: 12px;
    }

    .sidebar-icon {
        width: auto;
    }

    .editor-main {
        padding: 20px 16px;
    }

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

/* --- Image Upload Drop Zone --- */
.image-drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-drop-zone:hover {
    border-color: var(--accent);
    background: rgba(99, 102, 241, 0.04);
}

.image-drop-zone.dragover {
    border-color: var(--accent);
    background: rgba(99, 102, 241, 0.1);
    border-style: solid;
}

.image-drop-placeholder {
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.6;
}

.image-drop-placeholder span {
    font-size: 12px;
    opacity: 0.6;
}

.image-drop-preview {
    max-width: 100%;
    display: block;
    margin: 0 auto;
}

/* --- HTML Toolbar --- */
.html-toolbar {
    display: flex;
    gap: 4px;
    padding: 6px 8px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: var(--radius) var(--radius) 0 0;
}

.html-toolbar+.field-textarea {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
}

.html-toolbar-btn {
    padding: 3px 10px;
    font-size: 12px;
    font-weight: 600;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
    font-family: monospace;
}

.html-toolbar-btn:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* --- iOS Toggle --- */
.ios-toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
    cursor: pointer;
}

.ios-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.ios-toggle-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--border);
    border-radius: 24px;
    transition: background 0.3s;
}

.ios-toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.3s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.ios-toggle input:checked+.ios-toggle-slider {
    background: #34c759;
}

.ios-toggle input:checked+.ios-toggle-slider::before {
    transform: translateX(20px);
}