:root {
  --bg-deep: #0a0e1a;
  --bg-card: #131a2b;
  --bg-card-hover: #1a2236;
  --bg-option: #1a2236;
  --bg-option-active: #1c2a4a;
  --border: rgba(255, 255, 255, 0.08);
  --border-active: #4a7eff;
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.7);
  --text-tertiary: rgba(255, 255, 255, 0.5);
  --accent-blue: #4a7eff;
  --accent-cyan: #50e3c2;
  --accent-green: #4ade80;
  --accent-red: #ff6b6b;
  --gradient-primary: linear-gradient(90deg, #4a7eff 0%, #50e3c2 100%);
  --gradient-button: linear-gradient(90deg, #3b6cf5 0%, #5b8bff 100%);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  background: var(--bg-deep);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", "Meiryo", sans-serif;
  font-feature-settings: "palt";
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

body {
  background:
    radial-gradient(ellipse at top right, rgba(74, 126, 255, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at bottom left, rgba(80, 227, 194, 0.05) 0%, transparent 50%),
    var(--bg-deep);
  background-attachment: fixed;
}

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px;
  min-height: 100vh;
}

.screen {
  background: var(--bg-card);
  border-radius: 20px;
  padding: 32px 24px;
  border: 1px solid var(--border);
  animation: fadeIn 0.3s ease-out;
}

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

/* ===== Start Screen ===== */
.start-meta {
  color: var(--accent-blue);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 14px;
  letter-spacing: 0.02em;
}

.start-title {
  font-size: 28px;
  font-weight: 800;
  line-height: 1.35;
  margin-bottom: 18px;
  letter-spacing: -0.01em;
}

.start-desc {
  color: var(--text-secondary);
  font-size: 15px;
  margin-bottom: 22px;
  line-height: 1.7;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 28px;
}

.tag {
  display: inline-block;
  padding: 8px 16px;
  background: var(--bg-option);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

.btn-primary {
  width: 100%;
  padding: 18px;
  background: var(--gradient-button);
  border: none;
  border-radius: 999px;
  color: white;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 8px 24px rgba(74, 126, 255, 0.3);
  font-family: inherit;
  letter-spacing: 0.02em;
}

.btn-primary:active {
  transform: scale(0.98);
  box-shadow: 0 4px 12px rgba(74, 126, 255, 0.3);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ===== Quota row (start screen) ===== */
.quota-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(74, 126, 255, 0.06);
  border: 1px solid rgba(74, 126, 255, 0.18);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 18px;
  font-size: 13px;
  color: var(--text-secondary);
}

.quota-row strong {
  color: var(--accent-blue);
  font-weight: 700;
}

/* ===== Question Screen ===== */
.q-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 14px;
}

.q-num {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
}

.q-percent {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}

.progress-bar {
  height: 5px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 24px;
}

.progress-fill {
  height: 100%;
  background: var(--gradient-primary);
  border-radius: 999px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 12px rgba(80, 227, 194, 0.4);
}

.q-title {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.4;
  margin-bottom: 22px;
  letter-spacing: -0.01em;
}

.options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
}

.option {
  width: 100%;
  padding: 18px 20px;
  background: var(--bg-option);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}

.option:hover {
  background: var(--bg-card-hover);
}

.option.selected {
  background: var(--bg-option-active);
  border-color: var(--border-active);
  box-shadow: 0 0 0 1px var(--border-active), 0 0 16px rgba(74, 126, 255, 0.2);
}

.option:active {
  transform: scale(0.99);
}

/* ===== Free-text input ===== */
.freetext-block {
  margin-bottom: 18px;
}

.freetext-label {
  display: block;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
  line-height: 1.5;
}

.freetext-label .optional {
  color: var(--text-tertiary);
  font-weight: 500;
  margin-left: 6px;
  font-size: 12px;
}

.freetext-input {
  width: 100%;
  min-height: 84px;
  padding: 14px 16px;
  background: var(--bg-option);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  color: var(--text-primary);
  font-size: 14.5px;
  font-family: inherit;
  line-height: 1.6;
  resize: vertical;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.freetext-input:focus {
  outline: none;
  border-color: var(--border-active);
  box-shadow: 0 0 0 1px var(--border-active);
}

.freetext-input::placeholder {
  color: var(--text-tertiary);
}

/* ===== Action row (Question screen submit) ===== */
.action-row {
  margin-bottom: 14px;
}

.btn-next {
  width: 100%;
  padding: 16px;
  background: var(--gradient-button);
  border: none;
  border-radius: 999px;
  color: white;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
  font-family: inherit;
  box-shadow: 0 6px 20px rgba(74, 126, 255, 0.25);
}

.btn-next:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-next:not(:disabled):active {
  transform: scale(0.99);
}

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

.btn-secondary {
  flex: 1;
  padding: 14px;
  background: var(--bg-option);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.btn-secondary:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ===== Loading state ===== */
.loading {
  text-align: center;
  padding: 48px 24px;
}

.spinner {
  display: inline-block;
  width: 36px;
  height: 36px;
  border: 3px solid rgba(74, 126, 255, 0.2);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  margin-top: 18px;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.6;
}

.loading-sub {
  margin-top: 8px;
  color: var(--text-tertiary);
  font-size: 12.5px;
}

/* ===== Error state ===== */
.error-block {
  background: rgba(255, 107, 107, 0.06);
  border: 1px solid rgba(255, 107, 107, 0.25);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 16px;
  color: var(--accent-red);
  font-size: 13.5px;
  line-height: 1.6;
}

/* ===== Result Screen ===== */
.result-label {
  color: var(--accent-blue);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.result-prefix {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 4px;
  color: var(--text-primary);
}

.result-type {
  font-size: 30px;
  font-weight: 800;
  line-height: 1.3;
  color: #6ea5ff;
  margin-bottom: 18px;
  letter-spacing: -0.01em;
}

.result-headline {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.6;
  margin-bottom: 16px;
}

.result-body {
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.85;
  margin-bottom: 22px;
}

.priority-step {
  background: rgba(74, 222, 128, 0.08);
  border: 1px solid rgba(74, 222, 128, 0.25);
  border-radius: 12px;
  padding: 14px 16px;
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 8px;
}

.priority-step strong {
  color: var(--accent-green);
  font-weight: 700;
}

.section {
  margin-top: 32px;
}

.section-label {
  color: var(--accent-blue);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.15em;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.section-title {
  font-size: 24px;
  font-weight: 800;
  line-height: 1.4;
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}

.section-desc {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 18px;
  line-height: 1.7;
}

.step-card, .day-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 18px;
  margin-bottom: 12px;
  transition: border-color 0.2s ease;
}

.step-card.priority {
  border-color: rgba(74, 222, 128, 0.3);
  background: rgba(74, 222, 128, 0.04);
}

.step-tag, .day-tag {
  color: var(--accent-blue);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.1em;
  margin-bottom: 6px;
}

.step-card.priority .step-tag {
  color: var(--accent-green);
}

.step-title, .day-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 6px;
  line-height: 1.5;
}

.step-body, .day-body {
  color: var(--text-secondary);
  font-size: 13.5px;
  line-height: 1.7;
}

.day-time {
  color: var(--text-tertiary);
  font-size: 12.5px;
  margin-bottom: 8px;
}

.day-memo {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  padding: 10px 12px;
  margin-top: 12px;
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.day-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 12px;
  cursor: pointer;
  user-select: none;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
}

.day-check input {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--text-tertiary);
  border-radius: 5px;
  flex-shrink: 0;
  margin-top: 2px;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}

.day-check input:checked {
  background: var(--accent-blue);
  border-color: var(--accent-blue);
}

.day-check input:checked::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 0;
  width: 5px;
  height: 10px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.day-check input:checked + span {
  color: var(--text-primary);
  text-decoration: line-through;
  text-decoration-color: rgba(255, 255, 255, 0.3);
}

.restart-area {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.footer-note {
  text-align: center;
  color: var(--text-tertiary);
  font-size: 11.5px;
  margin-top: 20px;
  line-height: 1.6;
}

/* ===== History ===== */
.history-section {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.history-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-secondary);
  letter-spacing: 0.04em;
}

.history-clear {
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 12px;
  cursor: pointer;
  padding: 4px 8px;
  font-family: inherit;
}

.history-clear:hover {
  color: var(--accent-red);
}

.history-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color 0.2s ease;
  font-size: 13.5px;
}

.history-card:hover {
  border-color: var(--border-active);
}

.history-card-type {
  color: var(--accent-blue);
  font-weight: 700;
  margin-bottom: 4px;
  font-size: 14px;
}

.history-card-meta {
  color: var(--text-tertiary);
  font-size: 11.5px;
}

@media (max-width: 380px) {
  .start-title { font-size: 24px; }
  .q-title { font-size: 20px; }
  .result-type { font-size: 26px; }
  .section-title { font-size: 20px; }
}
