:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #5d6875;
  --line: #d9e0e7;
  --paper: #f7f8f5;
  --panel: #ffffff;
  --teal: #1f7a72;
  --teal-dark: #135b55;
  --berry: #8f2d56;
  --gold: #b87918;
  --blue: #2e5e8e;
  --green: #52733d;
  --shadow: 0 18px 45px rgba(23, 32, 42, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #eef4f1 0%, var(--paper) 42%, #f3f1ea 100%);
}

body.locked .app-shell {
  display: none;
}

body:not(.locked) .login-view {
  display: none;
}

button,
textarea,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  padding: 28px;
}

.login-view {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 22px;
}

.login-panel {
  width: min(430px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.login-panel h1 {
  margin-bottom: 22px;
  font-size: 2rem;
}

.login-panel label {
  display: block;
  margin-bottom: 8px;
  font-weight: 700;
}

.login-panel .primary-button {
  width: 100%;
  margin-top: 14px;
}

.login-error {
  min-height: 22px;
  margin: 12px 0 0;
  color: #9d2834;
  font-weight: 700;
}

.hidden {
  display: none !important;
}

.topbar,
.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  max-width: 1280px;
  margin: 0 auto 22px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--teal-dark);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 4vw, 4rem);
  line-height: 1.02;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.7rem, 3vw, 3rem);
  line-height: 1.05;
}

h3 {
  margin-bottom: 14px;
  font-size: 1.15rem;
}

.topbar-actions,
.memo-actions,
.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.ghost-button,
.secondary-button,
.primary-button,
.record-button,
.back-button,
.icon-close,
.danger-button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 16px;
  color: var(--ink);
  background: var(--panel);
  box-shadow: 0 8px 20px rgba(23, 32, 42, 0.08);
}

.primary-button {
  color: #fff;
  background: var(--teal);
}

.secondary-button,
.ghost-button {
  border-color: var(--line);
}

.record-button {
  color: #fff;
  background: var(--berry);
}

.danger-button {
  color: #fff;
  background: #9d2834;
}

.record-button.recording {
  background: #b11f2c;
}

.back-button,
.icon-close {
  width: 46px;
  padding: 0;
  font-size: 1.5rem;
}

.org-chart {
  display: grid;
  grid-template-columns: repeat(12, minmax(64px, 1fr));
  gap: 18px;
  max-width: 1280px;
  margin: 0 auto;
  padding: 14px 0 36px;
}

.department-button {
  position: relative;
  min-height: 104px;
  border: 2px solid rgba(23, 32, 42, 0.08);
  border-radius: 8px;
  padding: 18px 14px;
  color: #fff;
  text-align: left;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.department-button::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.22), rgba(255,255,255,0));
}

.department-button span {
  position: relative;
  display: block;
  font-size: clamp(1rem, 1.6vw, 1.45rem);
  font-weight: 800;
  line-height: 1.16;
  overflow-wrap: anywhere;
}

.department-button small {
  position: relative;
  display: block;
  margin-top: 10px;
  font-size: 0.85rem;
  opacity: 0.9;
}

.department-button:hover,
.department-button:focus-visible {
  transform: translateY(-2px);
  outline: 3px solid rgba(31, 122, 114, 0.24);
}

.level-1 {
  grid-column: 5 / span 4;
}

.level-2-left {
  grid-column: 2 / span 3;
}

.level-2-mid {
  grid-column: 5 / span 4;
}

.level-2-right {
  grid-column: 9 / span 3;
}

.level-3-a {
  grid-column: 1 / span 3;
}

.level-3-b {
  grid-column: 4 / span 3;
}

.level-3-c {
  grid-column: 7 / span 3;
}

.level-3-d {
  grid-column: 10 / span 3;
}

.level-4-a {
  grid-column: 2 / span 2;
}

.level-4-b {
  grid-column: 4 / span 2;
}

.level-4-c {
  grid-column: 6 / span 2;
}

.level-4-d {
  grid-column: 8 / span 2;
}

.level-4-e {
  grid-column: 10 / span 2;
}

.custom-level {
  grid-column: span 3;
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 22px;
  max-width: 1280px;
  margin: 0 auto;
}

.ai-options,
.memo-panel {
  min-height: 590px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
}

.option-card {
  border-left: 5px solid var(--teal);
  margin-bottom: 14px;
  padding: 16px 18px;
  border-radius: 6px;
  background: #fbfcfb;
}

.option-card h4 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.option-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.memo-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.memo-head h3 {
  margin-bottom: 4px;
}

#saveStatus,
.audio-note {
  color: var(--muted);
  font-size: 0.9rem;
}

#memoField,
#summaryText,
#projectContextField,
#newDepartmentTitle {
  display: block;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  color: var(--ink);
  background: #fff;
  line-height: 1.45;
}

#memoField:focus,
#summaryText:focus,
#projectContextField:focus,
#newDepartmentTitle:focus {
  outline: 3px solid rgba(31, 122, 114, 0.18);
  border-color: var(--teal);
}

#memoField,
#summaryText,
#projectContextField {
  min-height: 390px;
  resize: vertical;
}

#projectContextField {
  min-height: 180px;
}

#newDepartmentTitle {
  min-height: 44px;
}

.memo-actions {
  justify-content: flex-end;
  margin-top: 12px;
}

dialog {
  width: min(920px, calc(100vw - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 26px 70px rgba(23, 32, 42, 0.25);
}

dialog::backdrop {
  background: rgba(23, 32, 42, 0.42);
}

.summary-dialog {
  padding: 22px;
}

.summary-dialog header,
.settings-dialog header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.settings-dialog {
  padding: 22px;
}

.settings-section {
  margin-bottom: 20px;
}

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

.custom-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.custom-pill {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  color: var(--muted);
}

.button-edit-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.button-edit-actions {
  display: flex;
  gap: 8px;
}

#summaryText {
  min-height: 420px;
}

.dialog-actions {
  justify-content: flex-end;
  margin-top: 14px;
}

@media (max-width: 880px) {
  .app-shell {
    padding: 18px;
  }

  .topbar,
  .detail-header,
  .memo-head,
  .add-row,
  .button-edit-row,
  .button-edit-actions {
    display: flex;
    align-items: stretch;
    flex-direction: column;
  }

  .org-chart,
  .detail-layout {
    display: block;
  }

  .department-button {
    width: 100%;
    margin-bottom: 12px;
  }

  .ai-options,
  .memo-panel {
    min-height: auto;
    margin-bottom: 16px;
  }
}
