:root {
  color-scheme: light;
  --bg: #fbfaf5;
  --surface: rgba(255, 255, 251, 0.86);
  --surface-strong: #fffefa;
  --line: rgba(32, 45, 36, 0.1);
  --line-strong: rgba(32, 45, 36, 0.16);
  --text: #101713;
  --muted: #667168;
  --soft: #eef5ec;
  --green: #4f8b67;
  --green-dark: #2d6246;
  --accent: #c69a52;
  --shadow: 0 18px 55px rgba(32, 45, 36, 0.08);
  --radius: 18px;
  font-family: "Inter", "Noto Sans JP", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 8% -10%, rgba(97, 142, 101, 0.18), transparent 30%),
    radial-gradient(circle at 90% 0%, rgba(198, 154, 82, 0.12), transparent 34%),
    linear-gradient(180deg, #fffefa 0%, var(--bg) 46%, #f7f5ee 100%);
  color: var(--text);
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
}

.app-shell {
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr);
  min-height: 100vh;
}

.side-rail {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px 14px;
  border-right: 1px solid var(--line);
  background: rgba(255, 254, 250, 0.72);
  backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
  padding: 8px;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: #0d100e;
  color: #fffefa;
  font-size: 12px;
  font-weight: 700;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 14px;
}

.brand small {
  margin-top: 1px;
  color: var(--muted);
  font-size: 11px;
}

.rail-nav {
  display: grid;
  gap: 6px;
}

.rail-nav button,
.category-bar button,
.action-row button {
  cursor: pointer;
}

.rail-nav button {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 0 10px;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  text-align: left;
}

.rail-nav button i {
  font-size: 16px;
}

.rail-nav button.active,
.rail-nav button:hover {
  background: var(--soft);
  color: var(--green-dark);
}

.rail-status {
  margin-top: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 251, 0.72);
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(79, 139, 103, 0.12);
  flex: 0 0 auto;
}

.rail-status strong,
.rail-status small {
  display: block;
}

.rail-status strong {
  font-size: 13px;
}

.rail-status small {
  color: var(--muted);
  font-size: 11px;
}

.workspace {
  min-width: 0;
  padding: 16px 20px 26px;
}

.topbar {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.topbar h1 {
  margin-top: 2px;
  font-size: 22px;
  line-height: 1.15;
  font-weight: 650;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
}

.topbar-actions button {
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 251, 0.7);
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}

.topbar-actions button:hover,
.topbar-actions button.active {
  border-color: rgba(79, 139, 103, 0.32);
  background: var(--soft);
  color: var(--green-dark);
}

.work-grid {
  display: grid;
  grid-template-columns: minmax(300px, 0.82fr) minmax(0, 1.65fr);
  gap: 14px;
  align-items: start;
}

.input-card,
.result-card,
.detail-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.input-card {
  padding: 16px;
}

.card-head,
.result-header,
.panel-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.card-head h2,
.panel-title h2 {
  margin-top: 4px;
  font-size: 17px;
  line-height: 1.25;
}

.save-state,
.confidence {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 25px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--green-dark);
  font-size: 12px;
  white-space: nowrap;
}

.photo-drop {
  position: relative;
  display: block;
  margin-top: 14px;
  min-height: 185px;
  overflow: hidden;
  border-radius: 15px;
  border: 1px solid var(--line-strong);
  cursor: pointer;
  background: #edf2ec;
}

.photo-drop input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.photo-drop img {
  display: block;
  width: 100%;
  height: 185px;
  object-fit: cover;
}

#previewImage:not([hidden]) {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.drop-badge,
.photo-drop strong,
.photo-drop small {
  position: absolute;
  z-index: 2;
  left: 12px;
  color: #fffefa;
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.32);
}

.drop-badge {
  top: 10px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 8px;
  border-radius: 999px;
  background: rgba(17, 28, 20, 0.45);
  font-size: 11px;
}

.photo-drop strong {
  bottom: 30px;
  font-size: 15px;
}

.photo-drop small {
  right: 12px;
  bottom: 12px;
  font-size: 11px;
  line-height: 1.35;
}

.field-stack {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.vision-status {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 10px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(247, 249, 244, 0.78);
}

.vision-status i {
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  border-radius: 9px;
  background: var(--soft);
  color: var(--green-dark);
  flex: 0 0 auto;
}

.vision-status strong,
.vision-status span {
  display: block;
}

.vision-status strong {
  font-size: 12px;
}

.vision-status span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.vision-status[data-state="loading"] i {
  animation: spin 1.1s linear infinite;
}

.vision-status[data-state="ready"] {
  border-color: rgba(79, 139, 103, 0.28);
  background: rgba(238, 245, 236, 0.84);
}

.vision-status[data-state="error"] {
  border-color: rgba(198, 154, 82, 0.34);
  background: rgba(255, 248, 235, 0.8);
}

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

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

label span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 11px;
}

input,
select {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 251, 0.78);
  color: var(--text);
  padding: 0 11px;
  outline: none;
}

input:focus,
select:focus {
  border-color: rgba(79, 139, 103, 0.55);
  box-shadow: 0 0 0 3px rgba(79, 139, 103, 0.12);
}

.primary-action {
  width: 100%;
  height: 42px;
  margin-top: 14px;
  border-radius: 12px;
  background: #111713;
  color: #fffefa;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
}

.primary-action:hover {
  background: #1e2d24;
}

.result-card {
  overflow: hidden;
}

.result-hero {
  display: grid;
  grid-template-columns: 38% minmax(0, 1fr);
  min-height: 316px;
}

.result-hero > img {
  width: 100%;
  height: 100%;
  min-height: 316px;
  object-fit: cover;
}

.result-copy {
  padding: 22px;
  display: flex;
  flex-direction: column;
}

.result-header h2 {
  max-width: 680px;
  margin-top: 7px;
  font-size: 25px;
  line-height: 1.2;
  letter-spacing: 0;
}

.signal-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.signal-grid article {
  min-height: 62px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(247, 249, 244, 0.78);
}

.signal-grid span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.signal-grid strong {
  display: block;
  margin-top: 5px;
  font-size: 13px;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
  padding-top: 18px;
}

.action-row button,
.category-bar button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 0 0 auto;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 251, 0.74);
  color: var(--text);
  white-space: nowrap;
}

.action-row button:hover,
.category-bar button:hover,
.category-bar button.active {
  border-color: rgba(79, 139, 103, 0.32);
  background: var(--soft);
  color: var(--green-dark);
}

.result-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  border-top: 1px solid var(--line);
}

.result-list > div {
  padding: 15px 16px;
  border-right: 1px solid var(--line);
  min-height: 106px;
}

.result-list > div:nth-child(3n) {
  border-right: 0;
}

.result-list strong {
  display: block;
  margin-bottom: 7px;
  font-size: 13px;
}

.result-list p,
.result-list li {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

.idea-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.idea-list li + li {
  margin-top: 6px;
}

.idea-list span {
  display: inline-flex;
  margin-right: 6px;
  color: var(--green-dark);
  font-weight: 650;
}

.category-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 13px 0;
  margin: 2px 0 0;
  background: linear-gradient(180deg, rgba(251, 250, 245, 0.94), rgba(251, 250, 245, 0.75));
  backdrop-filter: blur(16px);
}

.category-bar::-webkit-scrollbar {
  display: none;
}

.detail-stage {
  margin-top: 0;
}

.detail-panel {
  display: none;
  padding: 18px;
}

.detail-panel.active {
  display: block;
}

.workflow-grid,
.course-flow,
.memory-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 15px;
}

.workflow-grid div,
.course-flow div,
.memory-grid article,
.cost-warning,
.cost-table,
.idea-cards article,
.voice-box {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 251, 0.72);
}

.workflow-grid div,
.course-flow div,
.memory-grid article {
  padding: 14px;
}

.workflow-grid span,
.course-flow span,
.idea-cards span,
.memory-grid span {
  display: inline-flex;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.workflow-grid strong,
.course-flow strong,
.idea-cards strong,
.memory-grid strong {
  display: block;
  font-size: 14px;
  line-height: 1.35;
}

.workflow-grid p,
.course-flow p,
.idea-cards p,
.cost-warning p {
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

.course-flow {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.idea-cards {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-top: 15px;
}

.idea-cards article {
  overflow: hidden;
}

.idea-cards img {
  width: 100%;
  height: 118px;
  object-fit: cover;
  display: block;
}

.idea-cards article > span,
.idea-cards strong,
.idea-cards p {
  margin-left: 12px;
  margin-right: 12px;
}

.idea-cards article > span {
  margin-top: 12px;
}

.idea-cards p {
  margin-bottom: 13px;
}

.cost-layout {
  display: grid;
  grid-template-columns: 0.95fr 1.2fr;
  gap: 12px;
  margin-top: 15px;
}

.cost-warning {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 15px;
  background: rgba(255, 248, 235, 0.72);
}

.cost-warning i {
  color: var(--accent);
  font-size: 20px;
}

.cost-table {
  overflow: hidden;
}

.cost-table div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.cost-table div:last-child {
  border-bottom: 0;
}

.cost-table span {
  font-size: 13px;
}

.cost-table strong {
  font-size: 14px;
}

.cost-table small {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 11px;
}

.cost-table .total {
  background: var(--soft);
}

.memory-grid article i {
  display: block;
  width: 100%;
  height: 7px;
  margin-top: 12px;
  border-radius: 999px;
  background: #e7ece5;
  overflow: hidden;
}

.memory-grid article i::before {
  content: "";
  display: block;
  width: var(--value);
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}

.voice-box {
  margin-top: 15px;
  padding: 18px;
  display: grid;
  justify-items: start;
  gap: 10px;
}

.voice-bars {
  height: 34px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.voice-bars span {
  width: 5px;
  border-radius: 999px;
  background: var(--green);
  animation: bar 1.3s infinite ease-in-out;
}

.voice-bars span:nth-child(1) { height: 14px; }
.voice-bars span:nth-child(2) { height: 28px; animation-delay: -0.2s; }
.voice-bars span:nth-child(3) { height: 20px; animation-delay: -0.4s; }
.voice-bars span:nth-child(4) { height: 31px; animation-delay: -0.1s; }

.voice-box button {
  min-height: 38px;
  padding: 0 13px;
  border-radius: 11px;
  background: #111713;
  color: #fffefa;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
}

@keyframes bar {
  0%, 100% { transform: scaleY(0.62); opacity: 0.72; }
  50% { transform: scaleY(1); opacity: 1; }
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 76px minmax(0, 1fr);
  }

  .brand span:last-child,
  .rail-nav span,
  .rail-status div {
    display: none;
  }

  .brand,
  .rail-nav button {
    justify-content: center;
  }

  .work-grid,
  .cost-layout {
    grid-template-columns: 1fr;
  }

  .result-hero {
    grid-template-columns: 300px minmax(0, 1fr);
  }

  .workflow-grid,
  .course-flow,
  .memory-grid,
  .idea-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
  }

  .side-rail {
    position: sticky;
    z-index: 10;
    top: 0;
    height: auto;
    padding: 8px 10px;
    flex-direction: row;
    align-items: center;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .brand {
    padding: 0;
  }

  .brand-mark {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    font-size: 10px;
  }

  .rail-nav {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    flex: 1;
  }

  .rail-nav::-webkit-scrollbar {
    display: none;
  }

  .rail-nav button {
    width: 34px;
    height: 34px;
    min-height: 34px;
    padding: 0;
    flex: 0 0 auto;
  }

  .rail-status {
    display: none;
  }

  .workspace {
    padding: 12px 10px 22px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .topbar-actions {
    justify-content: flex-start;
  }

  .field-row,
  .signal-grid,
  .result-list,
  .workflow-grid,
  .course-flow,
  .memory-grid,
  .idea-cards {
    grid-template-columns: 1fr;
  }

  .result-hero {
    display: block;
  }

  .result-hero > img {
    height: 220px;
    min-height: 220px;
  }

  .result-copy {
    padding: 16px;
  }

  .result-header {
    display: block;
  }

  .confidence {
    margin-top: 10px;
  }

  .result-header h2 {
    font-size: 22px;
  }

  .result-list > div {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .result-list > div:last-child {
    border-bottom: 0;
  }

  .category-bar {
    top: 50px;
  }

  .detail-panel {
    padding: 14px;
  }
}
