:root {
    --bg: #0f172a;
    --bg-soft: #111827;
    --panel: rgba(15, 23, 42, 0.84);
    --panel-strong: #111827;
    --line: rgba(148, 163, 184, 0.2);
    --text: #e5eefc;
    --muted: #9fb2cc;
    --accent: #ff8fab;
    --accent-2: #67e8f9;
    --accent-3: #fbbf24;
    --success: #34d399;
    --shadow: 0 18px 50px rgba(2, 8, 23, 0.45);
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    min-height: 100%;
    background:
        radial-gradient(circle at top, rgba(255, 143, 171, 0.22), transparent 28%),
        radial-gradient(circle at 20% 20%, rgba(103, 232, 249, 0.12), transparent 25%),
        linear-gradient(180deg, #081120 0%, #0b1220 100%);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "Yu Gothic UI", sans-serif;
}

body {
    display: flex;
    justify-content: center;
    padding: 14px;
}

.app-shell {
    width: min(430px, 100%);
    min-height: calc(100vh - 28px);
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.88), rgba(15, 23, 42, 0.96));
    border: 1px solid var(--line);
    border-radius: 30px;
    box-shadow: var(--shadow);
    overflow: hidden;
    position: relative;
}

.hero {
    padding: 26px 22px 20px;
    background:
        radial-gradient(circle at 20% 10%, rgba(255, 143, 171, 0.35), transparent 26%),
        radial-gradient(circle at 90% 0%, rgba(103, 232, 249, 0.22), transparent 18%),
        linear-gradient(135deg, rgba(17, 24, 39, 0.96), rgba(30, 41, 59, 0.96));
    border-bottom: 1px solid var(--line);
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    font-size: 12px;
    letter-spacing: .08em;
}

.hero h1 {
    margin: 12px 0 10px;
    font-size: 32px;
    line-height: 1.1;
}

.hero p, .section-head p, .card-head p, .status-card p, .soon-card p, .note-card p {
    color: var(--muted);
    line-height: 1.7;
}

.hero-actions, .actions {
    display: flex;
    gap: 10px;
    margin-top: 18px;
    flex-wrap: wrap;
}

button, input, select {
    font: inherit;
}

button {
    border: 0;
    border-radius: 14px;
    padding: 13px 16px;
    cursor: pointer;
}

button:disabled {
    cursor: wait;
    opacity: .62;
}

button.primary, .primary {
    background: linear-gradient(135deg, var(--accent), #ffb4c7);
    color: #111827;
    font-weight: 700;
}

button.accent {
    background: linear-gradient(135deg, var(--accent-2), #b3f5ff);
    color: #09111d;
    font-weight: 700;
}

button.ghost {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
}

.button-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    border-radius: 14px;
    padding: 0 16px;
    text-decoration: none;
    font-weight: 700;
}

.ghost-link {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
}

.content {
    padding: 16px 14px 88px;
}

.panel {
    display: none;
    animation: fade .22s ease-out;
}

.panel.active {
    display: block;
}

.panel h2 {
    margin: 0 0 10px;
    font-size: 22px;
}

.feature-grid, .status-grid, .two-col {
    display: grid;
    gap: 12px;
}

.feature-grid {
    grid-template-columns: 1fr;
    margin-top: 16px;
}

.feature-grid article, .card, .status-card, .soon-card, .note-card, .form-card, .history-item, .empty-state {
    background: rgba(17, 24, 39, 0.85);
    border: 1px solid var(--line);
    border-radius: 22px;
    padding: 16px;
}

.form-card label, .free-input {
    display: grid;
    gap: 8px;
    margin-bottom: 14px;
}

label span, legend {
    color: var(--muted);
    font-size: 13px;
}

.field-help {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.6;
}

.selection-status {
    display: block;
    padding: 10px 12px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 12px;
    background: rgba(2, 6, 23, 0.34);
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
}

.selection-status.ready {
    border-color: rgba(52, 211, 153, 0.42);
    color: #a7f3d0;
}

.selection-status.error {
    border-color: rgba(251, 113, 133, 0.48);
    color: #fecdd3;
}

input[type="text"], input[type="file"] {
    width: 100%;
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 14px;
    background: rgba(2, 6, 23, 0.5);
    color: var(--text);
    padding: 13px 14px;
}

input[type="password"] {
    width: 100%;
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 14px;
    background: rgba(2, 6, 23, 0.5);
    color: var(--text);
    padding: 13px 14px;
}

fieldset {
    border: 0;
    padding: 0;
    margin: 0 0 14px;
}

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

.chip {
    position: relative;
}

.chip input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.chip span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.07);
    color: var(--text);
    border: 1px solid transparent;
}

.chip input:checked + span {
    border-color: var(--accent-2);
    background: rgba(103, 232, 249, 0.16);
}

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

.lock-shell {
    width: min(430px, 100%);
    min-height: calc(100vh - 28px);
    display: grid;
    place-items: center;
}

.lock-card {
    width: 100%;
    background:
        radial-gradient(circle at 10% 0%, rgba(255, 143, 171, 0.26), transparent 28%),
        radial-gradient(circle at 90% 0%, rgba(103, 232, 249, 0.22), transparent 24%),
        linear-gradient(180deg, rgba(17, 24, 39, 0.94), rgba(15, 23, 42, 0.98));
    border: 1px solid var(--line);
    border-radius: 30px;
    box-shadow: var(--shadow);
    padding: 28px 22px;
}

.lock-card h1 {
    margin: 14px 0 10px;
    font-size: 30px;
    line-height: 1.15;
}

.lock-card p {
    color: var(--muted);
    line-height: 1.7;
}

.lock-form {
    display: grid;
    gap: 14px;
    margin-top: 22px;
}

.lock-form label {
    display: grid;
    gap: 8px;
}

.lock-error {
    margin-top: 16px;
    padding: 12px 14px;
    border-radius: 14px;
    background: rgba(251, 113, 133, 0.14);
    border: 1px solid rgba(251, 113, 133, 0.35);
    color: #fecdd3;
    font-weight: 700;
}

.card-head h3, .history-item h3, .status-card h3 {
    margin: 0 0 6px;
}

.two-col {
    margin: 12px 0;
}

.suggestions, .edit-grid, .history-list {
    display: grid;
    gap: 10px;
}

.suggestions.empty, .edit-grid.empty {
    color: var(--muted);
}

.suggestion-item, .edit-item {
    display: grid;
    gap: 8px;
    grid-template-columns: 24px 1fr;
    align-items: start;
    padding: 12px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.05);
}

.suggestion-item input {
    margin-top: 5px;
}

.suggestion-item strong {
    display: block;
    font-size: 15px;
}

.suggestion-item small {
    color: var(--muted);
}

.edit-item {
    grid-template-columns: 1fr;
}

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

.edit-item .row {
    display: grid;
    gap: 8px;
}

.stamp-preview {
    width: 100%;
}

.preview-stage {
    position: relative;
    width: 100%;
    aspect-ratio: 370 / 320;
    overflow: hidden;
    border-radius: 18px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    background:
        linear-gradient(45deg, rgba(255, 255, 255, 0.78) 25%, transparent 25%),
        linear-gradient(-45deg, rgba(255, 255, 255, 0.78) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, rgba(255, 255, 255, 0.78) 75%),
        linear-gradient(-45deg, transparent 75%, rgba(255, 255, 255, 0.78) 75%),
        #e2e8f0;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0;
    background-size: 20px 20px;
}

.preview-character {
    position: absolute;
    left: 50%;
    top: 8px;
    width: 67%;
    aspect-ratio: 1;
    display: grid;
    place-items: center;
    overflow: hidden;
    border: 0;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.14);
    box-shadow: none;
    transform: translateX(-50%);
    transform-origin: center bottom;
}

.preview-character img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.preview-character span {
    color: #64748b;
    font-weight: 800;
    letter-spacing: .08em;
}

.preview-character.frame-circle {
    border-radius: 999px;
}

.preview-character.frame-rounded {
    border-radius: 30px;
}

.preview-character.frame-square {
    border-radius: 6px;
}

.preview-character.frame-none {
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

.preview-badges {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    display: flex;
    justify-content: space-between;
    gap: 6px;
    pointer-events: none;
}

.preview-badges span {
    max-width: 48%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.64);
    color: #f8fafc;
    font-size: 11px;
    font-weight: 700;
}

.preview-caption {
    position: absolute;
    left: 18px;
    right: 18px;
    bottom: 18px;
    min-height: 58px;
    display: grid;
    place-items: center;
    padding: 8px 12px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.9);
    border: 3px solid rgba(15, 23, 42, 0.12);
    box-shadow: 0 10px 22px rgba(15, 23, 42, 0.16);
    font-weight: 900;
    line-height: 1.16;
    text-align: center;
    word-break: keep-all;
    overflow-wrap: anywhere;
}

.preview-caption.direction-horizontal {
    writing-mode: horizontal-tb;
}

.preview-caption.direction-vertical {
    width: 72px;
    min-height: 0;
    padding: 12px 8px;
    writing-mode: vertical-rl;
    text-orientation: upright;
    letter-spacing: 0.08em;
}

.preview-caption.position-bottom {
    left: calc(18px + var(--bubble-offset, 0px));
    right: calc(18px - var(--bubble-offset, 0px));
    top: auto;
    bottom: 18px;
}

.preview-caption.position-top {
    left: calc(18px + var(--bubble-offset, 0px));
    right: calc(18px - var(--bubble-offset, 0px));
    top: 18px;
    bottom: auto;
}

.preview-caption.position-right {
    left: auto;
    right: 14px;
    top: calc(18px + var(--bubble-offset, 0px));
    bottom: calc(18px - var(--bubble-offset, 0px));
}

.preview-caption.position-left {
    left: 14px;
    right: auto;
    top: calc(18px + var(--bubble-offset, 0px));
    bottom: calc(18px - var(--bubble-offset, 0px));
}

.preview-caption.direction-horizontal.position-left,
.preview-caption.direction-horizontal.position-right {
    width: 96px;
    min-height: 0;
    padding: 10px 8px;
}

.preview-caption.direction-vertical.position-bottom,
.preview-caption.direction-vertical.position-top {
    width: auto;
    min-height: 58px;
    padding: 8px 12px;
}

.edit-item select, .edit-item input[type="color"], .edit-item input[type="range"] {
    width: 100%;
}

.history-item {
    display: grid;
    grid-template-columns: 72px 1fr;
    gap: 12px;
    align-items: center;
}

.thumb {
    width: 72px;
    height: 72px;
    border-radius: 18px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.06);
    display: grid;
    place-items: center;
}

.thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.thumb span {
    font-size: 24px;
    font-weight: 700;
}

.link {
    color: var(--accent-2);
    text-decoration: none;
}

.bottom-nav {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1px;
    background: rgba(148, 163, 184, 0.15);
    border-top: 1px solid var(--line);
}

.nav-item {
    background: rgba(15, 23, 42, 0.97);
    color: var(--muted);
    border-radius: 0;
    padding: 13px 4px;
    font-size: 12px;
}

.nav-item.active {
    color: var(--text);
    background: rgba(255, 255, 255, 0.08);
}

.result {
    margin-top: 12px;
    min-height: 24px;
    color: var(--accent-2);
}

.project-progress:empty {
    display: none;
}

.progress-box {
    display: grid;
    gap: 10px;
    padding: 13px;
    border: 1px solid rgba(103, 232, 249, 0.28);
    border-radius: 14px;
    background: rgba(2, 6, 23, 0.38);
    color: var(--text);
}

.progress-box.done {
    border-color: rgba(52, 211, 153, 0.38);
}

.upload-progress {
    width: 100%;
    height: 12px;
    overflow: hidden;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
}

.upload-progress::-webkit-progress-bar {
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
}

.upload-progress::-webkit-progress-value {
    border-radius: 999px;
    background: linear-gradient(90deg, var(--accent-2), var(--accent));
}

.upload-progress::-moz-progress-bar {
    border-radius: 999px;
    background: linear-gradient(90deg, var(--accent-2), var(--accent));
}

.form-error {
    padding: 12px 14px;
    border: 1px solid rgba(251, 113, 133, 0.48);
    border-radius: 14px;
    background: rgba(127, 29, 29, 0.2);
    color: #fecdd3;
    font-size: 13px;
    line-height: 1.6;
}

.progress-title {
    font-weight: 700;
}

.progress-meta, .progress-steps {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.progress-meta span, .progress-steps span {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.07);
    color: var(--muted);
    font-size: 12px;
}

.progress-steps span.active {
    background: rgba(103, 232, 249, 0.16);
    color: var(--text);
}

.status-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.empty-state {
    text-align: center;
    color: var(--muted);
}

.note-card {
    margin-top: 12px;
}

@keyframes fade {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (min-width: 700px) {
    body {
        padding: 18px;
    }
    .app-shell {
        min-height: calc(100vh - 36px);
    }
}
