:root {
  --ink: #171411;
  --ink-2: #302921;
  --muted: #756d64;
  --line: #e3dbcf;
  --canvas: #f5f1e8;
  --white: #fff;
  --cyan: #f5aa25;
  --cyan-strong: #b66a00;
  --green: #17b866;
  --danger: #dc3545;
  --ease-out: cubic-bezier(.23, 1, .32, 1);
  --shadow: 0 24px 80px rgba(4, 25, 47, .15);
}

*, *::before, *::after { box-sizing: border-box; }
html { min-height: 100%; color-scheme: light; -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; overscroll-behavior: none; }
body { min-height: 100dvh; margin: 0; color: var(--ink); background: var(--canvas); font-family: "Segoe UI Variable", "Aptos", system-ui, sans-serif; -webkit-font-smoothing: antialiased; overscroll-behavior: none; }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
button, a, [role="button"] { touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
[hidden] { display: none !important; }

.login-view { min-height: 100dvh; display: grid; place-items: center; padding: max(28px, env(safe-area-inset-top, 0px)) max(28px, env(safe-area-inset-right, 0px)) max(28px, env(safe-area-inset-bottom, 0px)) max(28px, env(safe-area-inset-left, 0px)); background: radial-gradient(circle at 15% 20%, rgba(245, 170, 37, .17), transparent 32%), linear-gradient(145deg, #11100f, #3a2410); }
.login-view::before { content: ""; position: fixed; inset: 0; pointer-events: none; opacity: .18; background-image: linear-gradient(rgba(103,232,249,.2) 1px, transparent 1px), linear-gradient(90deg, rgba(103,232,249,.2) 1px, transparent 1px); background-size: 56px 56px; mask-image: linear-gradient(to bottom, #000, transparent 78%); }
.login-card { position: relative; width: min(100%, 490px); padding: 38px; border: 1px solid rgba(255,255,255,.18); border-radius: 30px; background: rgba(255,255,255,.97); box-shadow: 0 30px 100px rgba(0,0,0,.32); }
.login-brand { display: flex; align-items: center; gap: 15px; padding-bottom: 28px; border-bottom: 1px solid var(--line); }
.brand-ring { width: 70px; height: 70px; padding: 4px; overflow: hidden; border-radius: 50%; background: #171411; color: #f5aa25!important; box-shadow: 0 0 0 1px rgba(245,170,37,.4); display:grid!important; place-items:center; font-size:2rem!important; font-weight:900; }
.brand-ring img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.login-brand div { display: grid; }
.login-brand span { color: var(--cyan-strong); font-size: .69rem; font-weight: 800; letter-spacing: .16em; }
.login-brand strong { font-size: 1.42rem; letter-spacing: -.035em; }
.login-copy { padding: 28px 0 20px; }
.eyebrow { margin: 0 0 10px; color: var(--cyan-strong); font-size: .72rem; font-weight: 850; letter-spacing: .15em; }
.login-copy h1 { max-width: 390px; margin: 0 0 12px; font-size: clamp(2rem, 8vw, 3.05rem); line-height: .98; letter-spacing: -.06em; }
.login-copy > p:last-child { margin: 0; color: var(--muted); line-height: 1.55; }
#login-form { display: grid; gap: 15px; }
#login-form label, .field { display: grid; gap: 7px; color: var(--ink-2); font-size: .82rem; font-weight: 750; }
input, textarea, select { width: 100%; border: 1px solid var(--line); border-radius: 12px; outline: 0; color: var(--ink); background: #fff; transition: border-color 160ms ease, box-shadow 160ms ease; }
input, select { min-height: 48px; padding: 0 14px; }
textarea { min-height: 112px; padding: 13px 14px; line-height: 1.5; resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: var(--cyan-strong); box-shadow: 0 0 0 4px rgba(18,201,235,.13); }
.button { min-height: 46px; padding: 0 20px; border: 0; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; gap: 14px; cursor: pointer; font-weight: 800; transition: transform 150ms var(--ease-out), background 150ms ease, opacity 150ms ease; }
.button:active, .icon-button:active, .sidebar-action:active, .nav-button:active { transform: scale(.97); }
.button-primary { color: #17100a; background: linear-gradient(135deg, #ffd36c, var(--cyan)); box-shadow: 0 12px 30px rgba(245,170,37,.22); }
.button-primary:disabled { cursor: wait; opacity: .55; }
#login-form .button { width: 100%; margin-top: 4px; }
#login-form .button b { font-size: 1.2rem; }
.form-error { min-height: 20px; margin: -3px 0; color: var(--danger); font-size: .82rem; font-weight: 700; }
.login-security { margin: 20px 0 0; color: var(--muted); font-size: .76rem; text-align: center; }
.login-security span { color: var(--green); font-weight: 900; }

.editor-app { min-height: 100dvh; display: grid; grid-template-columns: 270px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; padding: max(20px, env(safe-area-inset-top, 0px)) 15px max(20px, env(safe-area-inset-bottom, 0px)); color: #f5eee4; background: #11100f; border-right: 1px solid rgba(255,255,255,.08); z-index: 20; }
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 8px 9px 20px; color: inherit; text-decoration: none; }
.sidebar-brand img { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; }
.sidebar-brand span { display: grid; }
.sidebar-brand strong { color: #fff; letter-spacing: -.02em; }
.sidebar-brand small { color: #7f9db8; }
.sidebar-label { padding: 16px 12px 8px; color: #607f9e; font-size: .65rem; font-weight: 850; letter-spacing: .15em; }
#section-nav { min-height: 0; flex: 1; display: grid; align-content: start; gap: 3px; overflow-y: auto; scrollbar-width: thin; }
.nav-button { width: 100%; min-height: 42px; display: flex; align-items: center; gap: 10px; padding: 0 12px; border: 0; border-radius: 10px; color: #9db4c9; background: transparent; cursor: pointer; text-align: left; transition: transform 150ms var(--ease-out), color 150ms ease, background 150ms ease; }
.nav-button::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #31516d; }
.nav-button.is-active { color: #fff; background: rgba(18,201,235,.14); }
.nav-button.is-active::before { background: var(--cyan); box-shadow: 0 0 12px var(--cyan); }
.sidebar-footer { display: grid; gap: 5px; padding-top: 13px; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-action { min-height: 42px; padding: 0 10px; display: flex; align-items: center; gap: 10px; border: 0; border-radius: 10px; color: #92abc2; background: transparent; cursor: pointer; text-align: left; transition: transform 150ms var(--ease-out), color 150ms ease, background 150ms ease; }
.sidebar-action:hover { color: #fff; background: rgba(255,255,255,.06); }

.workspace { min-width: 0; }
.workspace-header { position: sticky; top: 0; z-index: 10; min-height: 92px; display: flex; align-items: center; gap: 18px; padding: 18px clamp(22px, 4vw, 58px); border-bottom: 1px solid var(--line); background: rgba(255,255,255,.91); backdrop-filter: blur(18px); }
.workspace-header > div:first-of-type { min-width: 0; flex: 1; }
.workspace-header p { margin: 0 0 2px; color: var(--cyan-strong); font-size: .68rem; font-weight: 850; letter-spacing: .14em; }
.workspace-header h1 { margin: 0; overflow: hidden; font-size: clamp(1.4rem, 3vw, 2rem); letter-spacing: -.04em; text-overflow: ellipsis; white-space: nowrap; }
.header-actions { display: flex; align-items: center; gap: 15px; }
.save-state { color: var(--muted); font-size: .8rem; font-weight: 700; }
.save-state.is-dirty { color: #c27900; }
.menu-button { display: none; width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer; }
.content-form { width: min(100% - 44px, 1040px); margin: 36px auto 80px; }
.section-intro { margin-bottom: 25px; }
.section-intro h2 { margin: 0 0 7px; font-size: clamp(1.65rem, 4vw, 2.45rem); letter-spacing: -.05em; }
.section-intro p { margin: 0; color: var(--muted); }
.editor-card, .array-card, .object-group { border: 1px solid var(--line); border-radius: 18px; background: #fff; box-shadow: 0 8px 28px rgba(9,42,72,.06); }
.editor-card { padding: clamp(20px, 4vw, 30px); }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }
.field.is-wide { grid-column: 1 / -1; }
.field small { color: #8a9bab; font-weight: 500; }
.field input[type="color"] { min-height: 48px; padding: 5px; cursor: pointer; }
.boolean-field { min-height: 48px; display: flex; align-items: center; gap: 12px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 12px; background: #f8fbfc; }
.boolean-field input { width: 20px; min-height: 20px; accent-color: var(--cyan-strong); }
.image-editor { grid-column: 1 / -1; display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 18px; padding: 15px; border: 1px solid var(--line); border-radius: 15px; background: #f7fbfd; }
.image-preview { width: 150px; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 12px; background: #dce9ef; }
.image-controls { min-width: 0; display: grid; align-content: center; gap: 9px; }
.upload-button { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; padding: 0 14px; border: 1px solid #a8ddea; border-radius: 10px; color: #087f9d; background: #eafbff; cursor: pointer; font-weight: 800; }
.upload-button input { position: absolute; width: 1px; height: 1px; min-height: 0; opacity: 0; }
.object-group { grid-column: 1 / -1; padding: 18px; background: #f9fcfd; box-shadow: none; }
.object-title { margin: 0 0 16px; font-size: .78rem; color: #567189; letter-spacing: .08em; text-transform: uppercase; }
.array-editor { display: grid; gap: 15px; }
.array-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.array-toolbar h3 { margin: 0; font-size: 1rem; }
.add-button { min-height: 38px; padding: 0 13px; border: 1px solid #addfea; border-radius: 10px; color: #087e9d; background: #edfbfe; cursor: pointer; font-weight: 800; }
.array-list { display: grid; gap: 14px; }
.array-card { padding: 18px; box-shadow: none; }
.array-card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 14px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.array-card-header strong { font-size: .85rem; }
.item-actions { display: flex; gap: 6px; }
.icon-button { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 9px; color: #536c82; background: #fff; cursor: pointer; transition: transform 150ms var(--ease-out), color 150ms ease, border-color 150ms ease; }
.icon-button.danger { color: var(--danger); }
.empty-list { padding: 24px; border: 1px dashed #b7cbd5; border-radius: 14px; color: var(--muted); text-align: center; }
.status-toast { position: fixed; right: 22px; bottom: 22px; z-index: 100; max-width: min(390px, calc(100vw - 44px)); padding: 13px 17px; border-radius: 12px; color: #fff; background: #09223b; box-shadow: var(--shadow); opacity: 0; transform: translateY(12px); pointer-events: none; transition: opacity 180ms var(--ease-out), transform 180ms var(--ease-out); }
.status-toast.is-visible { opacity: 1; transform: translateY(0); }
.status-toast.is-error { background: #9b2430; }

@media (hover: hover) and (pointer: fine) {
  .button:hover { transform: translateY(-1px); }
  .nav-button:hover { color: #eaf7ff; background: rgba(255,255,255,.05); }
  .icon-button:hover { border-color: var(--cyan-strong); color: var(--cyan-strong); }
}

@media (max-width: 900px) {
  .editor-app { grid-template-columns: 230px minmax(0, 1fr); }
  .save-state { display: none; }
}

@media (max-width: 760px) {
  .login-view { padding: 15px; }
  .login-card { padding: 25px 21px; border-radius: 23px; }
  .editor-app { display: block; }
  .sidebar { position: fixed; left: 0; width: min(86vw, 300px); transform: translateX(-102%); transition: transform 240ms var(--ease-out); box-shadow: 24px 0 70px rgba(0,0,0,.3); }
  .sidebar.is-open { transform: translateX(0); }
  .menu-button { display: grid; place-items: center; }
  .workspace-header { min-height: 78px; padding: 13px 15px; }
  .workspace-header .button { min-height: 42px; padding: 0 13px; font-size: .8rem; }
  .content-form { width: min(100% - 26px, 1040px); margin-top: 22px; }
  .field-grid { grid-template-columns: 1fr; gap: 17px; }
  .image-editor { grid-template-columns: 92px minmax(0, 1fr); }
  .image-preview { width: 92px; }
  .array-card { padding: 14px; }
}

@media (pointer: coarse) {
  input, textarea, select { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
