:root {
    color-scheme: light;
    --bg: #f5f7f8;
    --surface: #ffffff;
    --surface-soft: #f1f5f6;
    --surface-muted: #e8eef0;
    --text: #172126;
    --muted: #5d6a72;
    --line: #d8e0e4;
    --line-strong: #c3cdd3;
    --accent: #0f6f68;
    --accent-strong: #0a5651;
    --accent-soft: #e4f3f1;
    --danger: #b42318;
    --success: #147d45;
    --shadow: 0 12px 30px rgba(23, 33, 38, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family:
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        "Microsoft YaHei",
        "PingFang SC",
        "Hiragino Sans",
        "Yu Gothic",
        "Meiryo",
        "Malgun Gothic",
        Arial,
        sans-serif;
    line-height: 1.5;
}

a {
    color: var(--accent-strong);
}

button,
.button-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    border: 0;
    border-radius: 6px;
    padding: 0 16px;
    background: var(--accent);
    color: #ffffff;
    font: inherit;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

button:hover,
.button-link:hover {
    background: var(--accent-strong);
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.62;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid rgba(15, 111, 104, 0.24);
    outline-offset: 2px;
}

button[hidden],
[hidden] {
    display: none !important;
}

.secondary-button,
.button-link.secondary {
    background: #334155;
}

.secondary-button:hover,
.button-link.secondary:hover {
    background: #1f2937;
}

.ghost-button {
    min-height: 34px;
    border: 1px solid var(--line);
    background: #ffffff;
    color: var(--muted);
    font-size: 0.92rem;
}

.ghost-button:hover {
    background: var(--surface-soft);
    color: var(--text);
}

.danger-text {
    color: var(--danger);
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    padding: 10px 12px;
    background: #ffffff;
    color: var(--text);
    font: inherit;
    line-height: 1.45;
}

textarea {
    resize: vertical;
}

label {
    display: grid;
    gap: 6px;
    color: var(--text);
    font-weight: 650;
}

h1,
h2,
h3,
h4,
p {
    margin-top: 0;
}

.public-builder-page {
    padding-bottom: 0;
}

.site-header {
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.96);
}

.site-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    width: min(1280px, calc(100% - 32px));
    margin: 0 auto;
    padding: 18px 0;
}

.brand-block {
    min-width: 0;
}

.brand-logo {
    color: var(--text);
    font-size: 1.35rem;
    font-weight: 850;
    text-decoration: none;
}

.brand-block p,
.header-actions p,
.panel-heading p,
.preview-kicker,
.draft-status {
    color: var(--muted);
}

.brand-block p,
.header-actions p {
    margin: 4px 0 0;
}

.header-actions {
    display: grid;
    justify-items: end;
    gap: 6px;
    text-align: right;
}

.builder-layout {
    display: grid;
    grid-template-columns: minmax(320px, 470px) minmax(0, 1fr);
    gap: 24px;
    width: min(1280px, calc(100% - 32px));
    margin: 0 auto;
    padding: 28px 0 38px;
}

.builder-panel,
.preview-panel,
.login-panel,
.content-page {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.builder-panel,
.preview-panel {
    padding: 22px;
}

.editor-panel {
    align-self: start;
}

.panel-heading {
    border-bottom: 1px solid var(--line);
    margin-bottom: 20px;
    padding-bottom: 16px;
}

.panel-heading h1 {
    margin-bottom: 6px;
    font-size: 1.65rem;
}

.privacy-helper {
    margin-bottom: 0;
    font-size: 0.94rem;
}

.builder-form {
    display: grid;
    gap: 18px;
}

.editor-section {
    display: grid;
    gap: 14px;
    border-top: 1px solid var(--line);
    padding-top: 18px;
}

.editor-section:first-child {
    border-top: 0;
    padding-top: 0;
}

.editor-section h2 {
    margin-bottom: 0;
    font-size: 1rem;
}

.editor-section-primary {
    padding-bottom: 2px;
}

.job-preset-panel {
    display: grid;
    gap: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    background: #fbfcfc;
}

.preset-helper,
.preset-empty-note,
.preset-status {
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.preset-suggestions {
    display: grid;
    gap: 12px;
}

.preset-suggestion-card {
    display: grid;
    gap: 14px;
    border-top: 1px solid var(--line);
    padding-top: 14px;
}

.preset-suggestion-heading {
    display: grid;
    gap: 3px;
}

.preset-suggestion-heading strong {
    color: var(--text);
}

.preset-suggestion-heading span {
    color: var(--muted);
    font-size: 0.88rem;
}

.preset-suggestion-group {
    display: grid;
    gap: 8px;
}

.preset-suggestion-group h3 {
    margin: 0;
    color: var(--text);
    font-size: 0.92rem;
}

.suggestion-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.suggestion-chip {
    min-height: 32px;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0 10px;
    background: #ffffff;
    color: var(--accent-strong);
    font-size: 0.88rem;
    font-weight: 720;
}

.suggestion-chip:hover,
.suggestion-chip.is-added {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.suggestion-chip.is-added::after {
    margin-left: 6px;
    content: "✓";
}

.recommended-template-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.recommended-template-card {
    display: grid;
    justify-items: start;
    min-height: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px;
    background: #ffffff;
    color: var(--text);
    text-align: left;
}

.recommended-template-card strong {
    font-size: 0.9rem;
}

.recommended-template-card span {
    color: var(--muted);
    font-size: 0.78rem;
    line-height: 1.3;
}

.recommended-template-card:hover,
.recommended-template-card.is-selected {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.preset-tip-list {
    display: grid;
    gap: 5px;
    margin: 0;
    padding-left: 18px;
    color: var(--muted);
    font-size: 0.9rem;
}

.photo-upload-panel {
    display: grid;
    gap: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    background: #fbfcfc;
}

.photo-upload-preview {
    display: grid;
    grid-template-columns: 82px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
}

.photo-editor-preview-frame {
    width: 82px;
    height: 82px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
}

.photo-editor-preview-frame img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform-origin: center;
}

.photo-file-meta {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.photo-file-meta strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.photo-file-meta span,
.photo-template-note {
    color: var(--muted);
    font-size: 0.9rem;
}

.photo-error {
    margin: 0;
    color: var(--danger);
    font-size: 0.9rem;
}

.photo-template-note {
    margin: 0;
}

.toggle-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
}

.toggle-row input {
    width: auto;
}

.photo-controls {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.photo-controls button {
    min-height: 34px;
    padding: 0 10px;
    font-size: 0.86rem;
}

.photo-controls button:disabled,
.toggle-row input:disabled {
    cursor: not-allowed;
    opacity: 0.52;
}

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

.inline-field {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 12px;
}

.section-title-row,
.preview-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.section-title-row h2,
.preview-toolbar h2 {
    margin-bottom: 0;
}

.section-title-row button {
    min-height: 36px;
    padding: 0 12px;
    font-size: 0.92rem;
}

.chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 32px;
}

.tag-chip {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    gap: 8px;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 6px 8px 6px 12px;
    background: var(--accent-soft);
    color: var(--accent-strong);
    font-weight: 700;
}

.chip-remove {
    width: 24px;
    min-width: 24px;
    height: 24px;
    min-height: 24px;
    border-radius: 999px;
    padding: 0;
    background: rgba(15, 111, 104, 0.12);
    color: var(--accent-strong);
    line-height: 1;
}

.chip-remove:hover {
    background: rgba(15, 111, 104, 0.22);
}

.empty-editor-note {
    margin: 0;
    color: var(--muted);
    font-size: 0.94rem;
}

.repeatable-item {
    display: grid;
    gap: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-top: 10px;
    padding: 14px;
    background: #fbfcfc;
}

.repeatable-item:first-child {
    margin-top: 0;
}

.repeatable-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.repeatable-item-header h3 {
    margin-bottom: 0;
    font-size: 0.96rem;
}

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

.field-full {
    grid-column: 1 / -1;
}

.draft-section {
    padding-bottom: 4px;
}

.draft-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.draft-status {
    min-height: 1.4em;
    margin: 0;
}

.preview-panel {
    align-self: start;
}

.preview-toolbar {
    margin-bottom: 18px;
}

.preview-kicker {
    margin-bottom: 2px;
    font-size: 0.86rem;
    font-weight: 750;
}

.preview-toolbar span {
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 5px 10px;
    color: var(--muted);
    font-size: 0.9rem;
    white-space: nowrap;
}

.cv-preview {
    min-height: 760px;
    background: #ffffff;
    color: #172126;
    overflow-wrap: anywhere;
    word-break: normal;
    line-break: auto;
}

.cv-preview-header {
    border-bottom: 2px solid #172126;
    margin-bottom: 24px;
    padding-bottom: 18px;
}

.cv-identity h2 {
    margin-bottom: 6px;
    font-size: 2rem;
    line-height: 1.16;
}

.cv-title-line {
    margin-bottom: 6px;
    color: #334155;
    font-size: 1.08rem;
    font-weight: 750;
}

.cv-target-line {
    margin-bottom: 0;
    color: var(--muted);
}

.cv-section {
    margin-top: 22px;
}

.cv-section-title {
    margin-bottom: 10px;
    color: #0f6f68;
    font-size: 1.05rem;
    line-height: 1.35;
}

.cv-contact-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 16px;
}

.cv-contact-item {
    display: grid;
    gap: 2px;
}

.cv-contact-label {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 750;
}

.cv-contact-value {
    color: var(--text);
}

.cv-summary-text {
    margin-bottom: 0;
    white-space: pre-line;
}

.cv-skill-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.cv-skill {
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    padding: 5px 10px;
    background: #f8fafc;
    color: #334155;
    font-weight: 700;
}

.cv-simple-list,
.cv-timeline {
    display: grid;
    gap: 12px;
}

.cv-simple-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 8px;
}

.cv-simple-row span,
.cv-item-meta {
    color: var(--muted);
}

.cv-item h4 {
    margin-bottom: 4px;
    font-size: 1rem;
    line-height: 1.35;
}

.cv-item-meta {
    margin-bottom: 6px;
}

.cv-bullets {
    display: grid;
    gap: 4px;
    margin: 8px 0 0;
    padding-left: 20px;
}

.mobile-download-bar {
    display: none;
}

.public-footer {
    width: min(1280px, calc(100% - 32px));
    margin: 0 auto;
    padding: 0 0 28px;
    color: var(--muted);
    font-size: 0.92rem;
    text-align: center;
}

.public-footer p {
    margin-bottom: 0;
}

.lead-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(15, 23, 42, 0.58);
}

.lead-modal {
    width: min(540px, 100%);
    max-height: calc(100vh - 36px);
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.26);
}

.lead-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    border-bottom: 1px solid var(--line);
    padding: 20px 22px 16px;
}

.lead-modal-header h2 {
    margin: 0;
    font-size: 1.22rem;
}

.lead-modal-close {
    flex: 0 0 auto;
    width: 34px;
    min-height: 34px;
    border: 1px solid var(--line);
    padding: 0;
    background: #ffffff;
    color: var(--muted);
    font-size: 1.2rem;
    line-height: 1;
}

.lead-modal-close:hover {
    background: var(--surface-soft);
    color: var(--text);
}

.lead-modal-form {
    display: grid;
    gap: 14px;
    padding: 20px 22px 22px;
}

.lead-modal-form > p {
    margin-bottom: 2px;
    color: var(--muted);
}

.lead-form-error {
    border: 1px solid #fecaca;
    border-radius: 6px;
    padding: 10px 12px;
    background: #fff1f0;
    color: var(--danger);
    font-weight: 700;
}

.lead-checkbox-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    color: var(--text);
    font-weight: 500;
}

.lead-checkbox-row input {
    width: auto;
    margin-top: 4px;
}

.lead-privacy-note {
    margin-bottom: 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.lead-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 2px;
}

.lead-honeypot {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.checkbox-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-weight: 600;
}

.checkbox-row input {
    width: auto;
    margin-top: 4px;
}

.alert {
    border-radius: 6px;
    margin-bottom: 16px;
    padding: 12px 14px;
}

.alert-error {
    background: #fff1f0;
    color: var(--danger);
}

.alert-success {
    background: #ecfdf3;
    color: var(--success);
}

.content-page {
    width: min(780px, calc(100% - 32px));
    margin: 40px auto;
    padding: 28px;
}

.admin-login-page {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
}

.login-panel {
    width: min(420px, 100%);
    padding: 28px;
}

.login-panel form {
    display: grid;
    gap: 16px;
}

.admin-page {
    background: #f8faf9;
}

.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 14px 24px;
    border-bottom: 1px solid var(--line);
    background: #ffffff;
}

.admin-brand {
    color: var(--text);
    font-weight: 800;
    text-decoration: none;
}

.admin-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.admin-nav a {
    color: var(--muted);
    font-weight: 700;
    text-decoration: none;
}

.admin-logout {
    display: flex;
    align-items: center;
    gap: 10px;
}

.admin-logout button,
.danger-button {
    min-height: 34px;
    padding: 0 10px;
    background: #991b1b;
    font-size: 0.9rem;
}

.admin-main {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 28px 0;
}

.admin-section {
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 24px;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.metric-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
}

.metric-card strong {
    display: block;
    overflow-wrap: anywhere;
    font-size: clamp(1.45rem, 2.4vw, 2rem);
    line-height: 1.18;
}

.metric-label {
    color: var(--muted);
    font-weight: 700;
}

.metric-note {
    display: block;
    margin-top: 8px;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 700;
}

.admin-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 22px;
}

.settings-form {
    display: grid;
    gap: 18px;
}

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

.admin-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 940px;
}

.admin-table th,
.admin-table td {
    border-bottom: 1px solid var(--line);
    padding: 11px 10px;
    text-align: left;
    vertical-align: top;
}

.admin-table th {
    color: var(--muted);
    font-size: 0.82rem;
    text-transform: uppercase;
}

.admin-table td span {
    display: block;
    color: var(--muted);
}

.admin-footer {
    padding: 18px 24px 28px;
    color: var(--muted);
    text-align: center;
}

@media (max-width: 980px) {
    .site-header-inner {
        align-items: flex-start;
        flex-direction: column;
    }

    .header-actions {
        justify-items: start;
        text-align: left;
    }

    .builder-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 720px) {
    .public-builder-page {
        padding-bottom: 78px;
    }

    .site-header-inner,
    .builder-layout {
        width: min(100% - 24px, 1280px);
    }

    .builder-layout {
        padding-top: 18px;
    }

    .builder-panel,
    .preview-panel {
        padding: 16px;
    }

    .form-grid,
    .repeatable-grid,
    .recommended-template-grid,
    .photo-controls,
    .cv-contact-grid,
    .metric-grid {
        grid-template-columns: 1fr;
    }

    .photo-upload-preview {
        grid-template-columns: 1fr;
    }

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

    .section-title-row,
    .preview-toolbar,
    .repeatable-item-header,
    .admin-logout {
        align-items: flex-start;
        flex-direction: column;
    }

    .section-title-row button {
        width: 100%;
    }

    .cv-preview {
        min-height: 640px;
    }

    .cv-identity h2 {
        font-size: 1.6rem;
    }

    .cv-simple-row {
        align-items: flex-start;
        flex-direction: column;
        gap: 2px;
    }

    .draft-actions button,
    .header-actions button {
        width: 100%;
    }

    .mobile-download-bar {
        position: fixed;
        right: 0;
        bottom: 0;
        left: 0;
        z-index: 30;
        display: block;
        border-top: 1px solid var(--line);
        padding: 10px 12px;
        background: rgba(255, 255, 255, 0.96);
        box-shadow: 0 -10px 28px rgba(23, 33, 38, 0.12);
    }

    .mobile-download-bar button {
        width: 100%;
    }

    .lead-modal-backdrop {
        align-items: end;
        padding: 12px;
    }

    .lead-modal {
        max-height: calc(100vh - 24px);
    }

    .lead-modal-header,
    .lead-modal-form {
        padding-right: 16px;
        padding-left: 16px;
    }

    .lead-modal-actions button {
        width: 100%;
    }

    .admin-header {
        align-items: flex-start;
        flex-direction: column;
    }
}

@media print {
    body {
        background: #ffffff !important;
    }

    .site-header,
    .builder-panel,
    .preview-toolbar,
    .public-footer,
    .mobile-download-bar,
    .admin-header,
    .admin-footer {
        display: none !important;
    }

    .builder-layout {
        display: block !important;
        width: auto !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .preview-panel {
        border: 0 !important;
        box-shadow: none !important;
        padding: 0 !important;
    }

    .cv-preview {
        min-height: auto !important;
        border: 0 !important;
        box-shadow: none !important;
        padding: 0 !important;
    }
}
