:root {
  --rail: #002855;
  --accent: #0066CC;
  --green: #5FAF4A;
  --text: #4a5565;
  --dark: #002855;
  --bg: #F1F1F1;
  --line: #d9dde0;
  --danger: #b3261e;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  font-family: proxima-nova, sans-serif, Arial, Helvetica;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.app { display: flex; min-height: 100vh; }

/* Rail */
.rail {
  width: 76px;
  flex: none;
  background: var(--rail);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 18px 0;
  gap: 6px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.logo { margin-bottom: 18px; display: block; width: 56px; height: 56px; }
.rail-btn {
  width: 100%;
  background: none;
  border: 0;
  color: #b9c1c7;
  font: inherit;
  font-size: 12px;
  line-height: 1.25;
  padding: 10px 4px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.rail-btn:hover { color: #fff; }
.rail-btn.active { color: var(--green); }
.rail-btn:focus-visible, .tab:focus-visible, .btn:focus-visible, .size-btn:focus-visible,
select:focus-visible, input[type="range"]:focus-visible, canvas:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

main { flex: 1; min-width: 0; }

/* Panels */
.panel { padding: 36px 40px; }
.panel.white { background: #fff; border-bottom: 1px solid #e6e8ea; }
.panel.gray { background: var(--bg); min-height: 70vh; }

h2 {
  margin: 0 0 24px;
  font-size: 28px;
  font-weight: 600;
  color: var(--dark);
  display: flex;
  align-items: baseline;
  gap: 12px;
}
.num { font-size: 20px; font-weight: 700; color: var(--accent); }
.lead { margin: -8px 0 28px; max-width: 60ch; }

.panel-head { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 12px; }
.panel-head h2 { margin-bottom: 12px; }

/* Size picker */
.sizes { display: flex; gap: 20px; overflow-x: auto; padding: 6px 6px 18px; align-items: center; }
.size-btn {
  position: relative;
  flex: none;
  background: #fff;
  border: 1px solid #dcdfe1;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  padding: 14px 14px 12px;
  font: inherit;
  color: var(--dark);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 190px;
  min-height: 150px;
  justify-content: center;
}
.size-btn:hover { border-color: #aab4bb; }
.size-btn[aria-checked="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.size-btn[aria-checked="true"]::after {
  content: "";
  position: absolute;
  right: -10px;
  bottom: -10px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M6 12.5l4 4 8-9' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/></svg>") center / 18px no-repeat;
}
.thumb {
  background: #ebecee;
  color: #6b7580;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.size-label { font-size: 15px; line-height: 1.25; text-align: center; }

/* Options */
.options { display: flex; flex-wrap: wrap; gap: 16px 24px; align-items: center; margin: 4px 0 18px; }
.options label { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; display: flex; align-items: center; gap: 8px; }
select {
  font: inherit;
  font-size: 14px;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: #fff;
  color: var(--dark);
}
.out-info { margin: 0; font-size: 14px; }

.msg { margin: 0 0 14px; padding: 10px 14px; background: #fff; border-left: 4px solid var(--accent); font-size: 14px; }
.msg.error { border-left-color: var(--danger); color: var(--danger); }

/* Tabs */
.tabs { display: flex; gap: 28px; }
.tab {
  background: none;
  border: 0;
  border-bottom: 3px solid transparent;
  font: inherit;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #8a949c;
  padding: 6px 0 8px;
  cursor: pointer;
}
.tab:hover { color: var(--dark); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Drop zone */
.drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-height: 420px;
  border: 2px dashed #b4bcc2;
  text-align: center;
  cursor: pointer;
  padding: 24px;
}
.drop.compact { min-height: 180px; }
.drop:hover, .drop.over { background: #e6f0fa; border-color: var(--accent); }
.drop:focus-within { outline: 2px solid var(--accent); outline-offset: 3px; }
.drop-text { font-size: 30px; font-weight: 600; line-height: 1.3; color: var(--text); }
.drop.compact .drop-text { font-size: 22px; }
.drop-sub { font-size: 14px; }

/* Editor */
.stage {
  display: flex;
  justify-content: center;
  padding: 24px;
  background: #e4e7e9;
  border: 1px solid var(--line);
}
#preview {
  display: block;
  cursor: grab;
  touch-action: none;
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #d6d9db 25%, transparent 25%, transparent 75%, #d6d9db 75%),
    linear-gradient(45deg, #d6d9db 25%, transparent 25%, transparent 75%, #d6d9db 75%);
  background-size: 16px 16px;
  background-position: 0 0, 8px 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
}
canvas.grabbing { cursor: grabbing; }
.warn { margin: 12px 0 0; padding: 10px 14px; background: #fff7e0; border-left: 4px solid #e0a800; font-size: 14px; color: #6b5200; }
.controls { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: center; margin: 16px 0 6px; }
.zoom { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.zoom input { width: 180px; }
.hint { margin: 6px 0 0; font-size: 13px; }

.btn {
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 3px;
  border: 1px solid var(--accent);
  cursor: pointer;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: #004c99; }
.btn.ghost { background: #fff; color: var(--accent); }
.btn.ghost:hover { background: #e6f0fa; }
.btn:disabled { opacity: 0.55; cursor: progress; }
.btn.small { padding: 6px 12px; font-size: 13px; }

/* Batch */
.batch-status { font-size: 14px; }
.batch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; margin-top: 18px; }
.card { background: #fff; border: 1px solid var(--line); padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.card .stage { padding: 10px; min-height: 100px; align-items: center; }
.card canvas { cursor: grab; touch-action: none; }
.card-name { font-size: 13px; color: var(--dark); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-note { font-size: 12px; color: #8a6d00; margin: 0; }
.card-actions { display: flex; gap: 8px; }

/* Guide */
.guide-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 24px; }
.guide-card { border: 1px solid var(--line); padding: 16px; background: #fff; }
.guide-box { background: #808285; color: #d6d8da; font-size: 13px; display: flex; align-items: center; justify-content: center; margin: 0 auto 14px; max-width: 100%; }
.guide-card h3 { margin: 0 0 6px; font-size: 17px; color: var(--dark); }
.guide-card dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; font-size: 14px; }
.guide-card dt { color: #8a949c; }
.guide-card dd { margin: 0; color: var(--dark); }

@media (max-width: 720px) {
  .rail { width: 60px; }
  .panel { padding: 24px 16px; }
  h2 { font-size: 24px; }
  .drop-text { font-size: 24px; }
}
