:root {
  --blue: #174a7c;
  --line: #d8dee8;
  --bg: #f5f7fb;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Malgun Gothic", system-ui, sans-serif;
  background: var(--bg);
  color: #111827;
}

header {
  background: var(--blue);
  color: white;
  padding: 14px 24px;
  display: grid;
  grid-template-columns: minmax(250px, 1fr) auto minmax(250px, 1fr);
  gap: 16px;
  align-items: center;
}

header h1 {
  margin: 0;
  font-size: 20px;
}

header .meta {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
  font-size: 13px;
}

select,
input,
button {
  font-family: inherit;
}

select,
input[type="file"],
input[type="text"] {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: white;
}

button {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  background: var(--blue);
  color: white;
  cursor: pointer;
  font-weight: 700;
}

button.secondary {
  background: #4b5563;
}

button.danger {
  background: #b91c1c;
}

main {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr) 380px;
  gap: 16px;
  padding: 16px;
  align-items: start;
}

.card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

h2 {
  font-size: 16px;
  margin: 0 0 12px;
}

h3 {
  font-size: 14px;
  margin: 18px 0 8px;
}

label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  margin: 10px 0 5px;
  color: #374151;
}

.dept {
  grid-column: 1;
  grid-row: 1 / span 3;
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 32px);
  overflow: auto;
}

.dept button {
  display: block;
  width: 100%;
  margin: 8px 0;
  background: #e8eef7;
  color: #183b63;
  text-align: left;
}

.dept button.active {
  background: var(--blue);
  color: white;
}

.dept select {
  width: 100%;
  margin: 8px 0 10px;
  font-weight: 700;
  color: #183b63;
}

.course-list {
  max-height: calc(100vh - 190px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
}

.course-wrapper {
  border-bottom: 1px solid var(--line);
}

.course-wrapper:last-child {
  border-bottom: 0;
}

.course {
  padding: 10px;
  cursor: pointer;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: flex-start;
}

.course.active {
  background: #e8f1ff;
  font-weight: 700;
}

.course small {
  color: #6b7280;
}

.course-title {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  min-width: 0;
}

.course-toggle {
  width: 18px;
  flex: 0 0 18px;
  font-weight: 900;
  color: #174a7c;
}

.course-name {
  min-width: 0;
}

.course-panel {
  display: none;
}

.course-panel #courseAccordionEditor {
  max-width: 1080px;
}

.course-section {
  padding: 10px 12px;
  background: #f1f5f9;
  border-bottom: 1px solid var(--line);
  font-weight: 800;
  color: #1f2937;
  position: sticky;
  top: 0;
}

.course-section.trash {
  background: #fff7ed;
  color: #9a3412;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.course-section.trash .trash-hint {
  font-size: 12px;
  color: #9a3412;
  opacity: 0.78;
}

.course.restore {
  background: #fffdf7;
}

.course-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.course-actions small {
  display: none;
}

.course-actions button {
  padding: 6px 9px;
  font-size: 12px;
  border-radius: 8px;
}

.course-actions button.restore {
  background: #0f766e;
  color: white;
}

.course-name {
  overflow: hidden;
  text-overflow: ellipsis;
}

.course-name small {
  display: block;
  line-height: 1.35;
  margin-top: 3px;
}

.empty-section {
  padding: 12px;
  color: #6b7280;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.top-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

.check-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.check {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px;
  background: #fafafa;
}

.result {
  white-space: pre-line;
  background: #f9fafb;
  border: 1px dashed var(--line);
  padding: 12px;
  border-radius: 10px;
  min-height: 90px;
  font-size: 13px;
}

.muted {
  color: #6b7280;
  font-size: 12px;
}

.pill {
  display: inline-block;
  border-radius: 999px;
  background: #eef2ff;
  color: #3730a3;
  padding: 3px 8px;
  font-size: 12px;
}

.status {
  margin-top: 12px;
  font-size: 13px;
  color: #374151;
}

a.download {
  display: inline-block;
  margin-top: 10px;
  padding: 10px 14px;
  background: #0f766e;
  color: white;
  text-decoration: none;
  border-radius: 10px;
  font-weight: 700;
}

.inline-add {
  display: flex;
  gap: 8px;
  align-items: center;
}

.inline-add input {
  flex: 1;
  min-width: 0;
}

.name-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  min-height: 36px;
}

.name-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 9px;
  border-radius: 999px;
  background: #e8eef7;
  color: #173b63;
  font-size: 13px;
  font-weight: 700;
}

.name-chip button {
  padding: 0 4px;
  border-radius: 999px;
  background: transparent;
  color: #173b63;
  font-size: 14px;
  line-height: 1;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

button.ok {
  background: #0f766e;
}

button.warn {
  background: #9a5b00;
}

.analysis-box {
  white-space: pre-line;
  background: #fffdf5;
  border: 1px solid #f1d38a;
  padding: 12px;
  border-radius: 10px;
  min-height: 160px;
  font-size: 13px;
  line-height: 1.55;
}

.analysis-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 18px;
}

.analysis-head h3 {
  margin: 0;
}

.saved-at {
  color: #6b7280;
  font-size: 12px;
  white-space: nowrap;
}

.improvement-box {
  white-space: pre-line;
  background: #f8fafc;
  border: 1px solid var(--line);
  padding: 12px;
  border-radius: 10px;
  min-height: 96px;
  font-size: 13px;
  line-height: 1.55;
  margin-top: 8px;
}

.tabs {
  display: flex;
  gap: 8px;
  margin: 6px 0 12px;
}

.tabs button {
  background: #e8eef7;
  color: #183b63;
  padding: 8px 12px;
}

.tabs button.active {
  background: var(--blue);
  color: white;
}

.tab-panel.hidden {
  display: none;
}

.saved-dot {
  color: #0f766e;
  font-weight: 800;
}

.name-chip.active {
  background: #174a7c;
  color: white;
}

.name-chip.active button {
  color: white;
}

textarea {
  width: 100%;
  min-height: 110px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  font-family: inherit;
  resize: vertical;
}

.preview-img {
  max-width: 160px;
  max-height: 80px;
  display: block;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.signature-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.signature-actions button {
  padding: 8px 10px;
  font-size: 12px;
}

.score-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 8px;
  align-items: center;
  margin-top: 8px;
}

.score-grid label {
  margin: 0;
  font-weight: 500;
  font-size: 12px;
}

.score-grid select {
  padding: 5px 7px;
  border-radius: 7px;
}

.accordion-editor-dock {
  display: block;
}

.file-list {
  margin-top: 7px;
  padding: 8px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: #f8fafc;
  min-height: 36px;
  font-size: 12px;
  color: #374151;
  white-space: pre-line;
}

.file-list.empty {
  color: #6b7280;
}

.file-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 0;
  border-bottom: 1px solid #eef2f7;
}

.file-row:last-child {
  border-bottom: 0;
}

.file-row button {
  padding: 4px 7px;
  font-size: 11px;
  border-radius: 7px;
}

.drop-target {
  display: block;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: white;
}

.drop-target.dragover {
  outline: 2px solid #0f766e;
  background: #ecfdf5;
}

.drop-target input[type="file"] {
  width: 100%;
}

.work-toolbar {
  grid-column: 2;
  grid-row: 1;
  position: sticky;
  top: 12px;
  z-index: 5;
}

.work-toolbar-grid {
  display: block;
}

.work-toolbar button {
  white-space: nowrap;
}

.work-toolbar .name-list {
  margin-top: 8px;
  min-height: auto;
}

.work-toolbar .actions {
  justify-content: flex-start;
  margin-top: 10px;
}

.toolbar-status {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}

.toolbar-status .status {
  margin-top: 0;
}

.header-course {
  text-align: center;
  font-size: 16px;
  font-weight: 900;
  color: white;
}

.header-course .pill {
  background: #e8eef7;
  color: #173b63;
  max-width: 520px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-panel {
  display: none;
  grid-column: 2;
  grid-row: 2;
}

body.admin-mode .admin-panel {
  display: block;
}

.admin-panel .drop-target {
  margin-bottom: 12px;
}

#editorCard {
  grid-column: 2;
  grid-row: 3;
  min-height: calc(100vh - 120px);
}

.admin-toggle button {
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12px;
  background: #e8eef7;
  color: #183b63;
}

.nav-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 16px;
}

.nav-title h3 {
  margin: 0;
  font-size: 14px;
}

.empty-workspace {
  min-height: 360px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #6b7280;
  border: 1px dashed var(--line);
  border-radius: 14px;
  background: #f8fafc;
  padding: 28px;
}

.editor-grid {
  display: block;
}

.analysis-column,
.evidence-column {
  min-width: 0;
}

.course-sticky-tab {
  position: sticky;
  top: 12px;
  z-index: 6;
  margin: -4px 0 14px;
  padding: 12px 16px;
  border-radius: 16px;
  background: linear-gradient(135deg, #174a7c, #0f766e);
  color: white;
  box-shadow: 0 8px 18px rgba(23, 74, 124, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.35);
}

.course-sticky-tab .tab-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  opacity: 0.86;
  margin-bottom: 4px;
}

.course-sticky-tab .tab-title {
  display: block;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.course-sticky-tab .tab-meta {
  display: block;
  font-size: 13px;
  font-weight: 700;
  opacity: 0.9;
  margin-top: 5px;
}

.course-sticky-tab.empty {
  background: #e8eef7;
  color: #173b63;
  box-shadow: none;
}

.evidence-card {
  grid-column: 3;
  grid-row: 1 / span 3;
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 32px);
  overflow: auto;
}

.evidence-column {
  position: static;
}

.evidence-column .check-grid {
  grid-template-columns: 1fr;
  gap: 8px;
}

.evidence-column .drop-target {
  margin-bottom: 10px;
}

@media print {
  body {
    background: #fff;
    color: #000;
  }
  header,
  .dept,
  .work-toolbar,
  .admin-panel,
  .evidence-card,
  .tabs,
  .signature-actions,
  .actions,
  .score-grid,
  textarea,
  label,
  p.muted,
  input[type="file"],
  #signaturePreview,
  #ownerSignaturePreview,
  #externalSignaturePreview {
    display: none !important;
  }
  main {
    display: block;
    padding: 0;
  }
  #editorCard {
    border: 0;
    box-shadow: none;
    padding: 0;
  }
  .analysis-box,
  .improvement-box {
    border: 1px solid #000;
    background: #fff;
  }
}
