:root {
  --bg: #f8f6f3;
  --surface: rgba(255, 255, 255, 0.92);
  --text: #2c2c2c;
  --text-muted: #6b6b6b;
  --accent: #a67c52;
  --accent-hover: #8b6a43;
  --border: #e6ddd3;
  --error-bg: #fef2f2;
  --error-border: #fecaca;
  --success-bg: #f0fdf4;
  --success-border: #bbf7d0;
  --radius: 18px;
  --shadow: 0 14px 40px rgba(75, 53, 35, 0.08);
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top, rgba(166, 124, 82, 0.12), transparent 30%),
    linear-gradient(180deg, #f5f0ea 0%, var(--bg) 24%, #f7f3ee 100%);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

.header {
  background: transparent;
  box-shadow: none;
}

.header-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 2rem 1.5rem 1.25rem;
}

.title {
  margin: 0;
  text-align: center;
  font-size: clamp(1.7rem, 3vw, 2.4rem);
  font-weight: 700;
  color: var(--text);
}

.main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 1.5rem 2.5rem;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(320px, 0.95fr);
  gap: 2rem;
  align-items: start;
}

.content-main {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.upload-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.file-input-hidden {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  overflow: hidden;
  z-index: -1;
  pointer-events: none;
}

.upload-zone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 220px;
  padding: 2rem;
  text-align: center;
  background: var(--surface);
  border: 2px dashed #d4cfc9;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.2s;
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--accent);
  background: #fdfbf9;
  transform: translateY(-2px);
}

.upload-zone.has-file {
  border-style: solid;
  border-color: #6e9870;
  background: #edf6ee;
}

.upload-zone.is-sending {
  border-style: solid;
  border-color: #6e9870;
  background: #edf6ee;
  cursor: progress;
}

.upload-zone.has-file .upload-text,
.upload-zone.is-sending .upload-text {
  color: #365c38;
}

.upload-zone.has-file .upload-hint,
.upload-zone.is-sending .upload-hint {
  color: #567158;
}

.upload-icon {
  width: 84px;
  height: 84px;
  margin-bottom: 1rem;
  background: url("icons/upload_file.png") center/contain no-repeat;
}

.upload-zone.has-file .upload-icon,
.upload-zone.is-sending .upload-icon {
  width: 120px;
  height: 120px;
  background-image: url("icons/success.png");
}

.upload-icon::after,
.upload-icon::before {
  content: none;
}

.upload-text {
  max-width: 28rem;
  font-size: 1.05rem;
  font-weight: 500;
}

.upload-hint {
  margin-top: 0.5rem;
  font-size: 0.92rem;
  color: var(--text-muted);
}

.btn {
  min-height: 48px;
  padding: 0.85rem 1.6rem;
  border: none;
  border-radius: 999px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: #5f8f64;
  color: #fff;
  align-self: flex-start;
  box-shadow: 0 10px 24px rgba(95, 143, 100, 0.22);
}

.btn-primary:hover:not(:disabled) {
  background: #4e7952;
  transform: translateY(-1px);
}

.btn-primary:focus-visible {
  outline: 3px solid rgba(95, 143, 100, 0.25);
  outline-offset: 2px;
}

.btn-secondary {
  min-height: 40px;
  padding: 0.55rem 1rem;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  box-shadow: none;
}

.btn-secondary:hover:not(:disabled) {
  background: #fdfbf9;
  transform: translateY(-1px);
}

.auth-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
  margin-left: auto;
}

.auth-user {
  color: var(--text-muted);
  font-size: 1.12rem;
  font-weight: 600;
}

.log-section,
.guide-section {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.log-section {
  overflow: hidden;
}

.log-title {
  margin: 0;
  padding: 1rem 1.25rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}

.log-placeholder {
  padding: 1.25rem;
  color: var(--text-muted);
  font-size: 0.9375rem;
}

.log-output {
  padding: 1.25rem;
}

.log-output.success {
  background: var(--success-bg);
  border-top: 1px solid var(--success-border);
}

.log-output.error {
  background: var(--error-bg);
  border-top: 1px solid var(--error-border);
}

.log-output pre {
  margin: 0;
  font-size: 0.875rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.log-list {
  margin: 0;
  padding-left: 1.25rem;
}

.log-list li {
  margin-bottom: 0.5rem;
}

.log-list li:last-child {
  margin-bottom: 0;
}

.log-heading {
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.log-heading.success {
  color: #166534;
}

.log-heading.error {
  color: #991b1b;
}

.log-message {
  color: var(--text);
}

.filename-suggestion {
  display: inline-block;
  margin-left: 0.15rem;
  padding: 0.08rem 0.42rem;
  border-radius: 7px;
  background: rgba(166, 124, 82, 0.16);
  font-family: "Consolas", "Courier New", monospace;
  font-weight: 700;
}

.filename-copy {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-top: 0.9rem;
  padding: 0.75rem;
  border: 1px solid rgba(153, 27, 27, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
}

.filename-copy-value {
  flex: 1;
  min-width: 0;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  background: rgba(166, 124, 82, 0.12);
  color: var(--text);
  font-family: "Consolas", "Courier New", monospace;
  font-size: 0.92rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.filename-copy-btn {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 0.5rem 0.85rem;
  border: none;
  border-radius: 8px;
  background: #5f8f64;
  color: #fff;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}

.filename-copy-btn:hover:not(:disabled) {
  background: #4e7952;
  transform: translateY(-1px);
}

.filename-copy-btn:disabled {
  opacity: 0.7;
  cursor: default;
  transform: none;
}

.guide-section {
  position: sticky;
  top: 1.5rem;
  padding: 1.5rem;
  border: 1px solid rgba(166, 124, 82, 0.14);
}

.guide-title {
  margin: 0 0 0.75rem;
  font-size: 1.15rem;
  font-weight: 700;
}

.guide-text {
  margin: 0 0 1rem;
  color: var(--text-muted);
}

.guide-list {
  margin: 0;
  padding-left: 1.2rem;
}

.guide-list li + li {
  margin-top: 0.9rem;
}

.guide-section code {
  padding: 0.1rem 0.35rem;
  border-radius: 6px;
  background: rgba(166, 124, 82, 0.12);
  font-family: "Consolas", "Courier New", monospace;
  font-size: 0.9em;
}

.briefs-section {
  margin-top: 2rem;
  background: var(--surface);
  border: 1px solid rgba(166, 124, 82, 0.14);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  overflow: hidden;
}

.briefs-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.briefs-section .briefs-header {
  border-bottom: none;
}

.briefs-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}

.briefs-count {
  margin: 0.2rem 0 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.briefs-open-btn {
  flex: 0 0 auto;
  background: #5f8f64;
  color: #fff;
  box-shadow: 0 10px 24px rgba(95, 143, 100, 0.18);
}

.briefs-open-btn:hover {
  background: #4e7952;
  transform: translateY(-1px);
}

.briefs-dialog {
  width: min(980px, calc(100vw - 2rem));
  max-height: min(760px, calc(100vh - 2rem));
  padding: 0;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
}

.briefs-dialog::backdrop {
  background: rgba(44, 44, 44, 0.42);
}

.briefs-dialog-panel {
  max-height: min(760px, calc(100vh - 2rem));
  background: var(--surface);
  border: 1px solid rgba(166, 124, 82, 0.14);
  border-radius: var(--radius);
  box-shadow: 0 24px 70px rgba(44, 44, 44, 0.22);
  overflow: hidden;
}

.briefs-dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.briefs-close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.briefs-close-btn:hover {
  background: #fdfbf9;
}

.briefs-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem 0.75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.briefs-search-label,
.briefs-sort-label {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
}

.briefs-search,
.briefs-sort {
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
}

.briefs-search {
  width: min(280px, 100%);
  padding: 0.45rem 0.7rem;
}

.briefs-sort {
  padding: 0.45rem 0.55rem;
}

.briefs-search:focus,
.briefs-sort:focus {
  outline: 3px solid rgba(166, 124, 82, 0.22);
  outline-offset: 1px;
}

.briefs-status {
  padding: 1rem 1.25rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.briefs-status.error {
  color: #991b1b;
  background: var(--error-bg);
  border-bottom: 1px solid var(--error-border);
}

.briefs-list {
  max-height: min(520px, calc(100vh - 250px));
  overflow: auto;
}

.brief-row {
  display: flex;
  align-items: center;
  gap: 2rem;
  width: 100%;
  min-width: max-content;
  padding: 0.85rem 1.25rem;
  border-top: 1px solid rgba(230, 221, 211, 0.72);
}

.brief-row:first-child {
  border-top: none;
}

.brief-title,
.brief-date {
  white-space: nowrap;
}

.brief-title {
  font-weight: 600;
}

.brief-date {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.required-mark {
  color: #c21f1f;
  font-weight: 700;
}

.footer {
  padding: 0 1.5rem calc(1.5rem + env(safe-area-inset-bottom));
}

.footer-text {
  margin: 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.95rem;
  letter-spacing: 0.03em;
}

.success-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  text-align: center;
}

.success-icon {
  width: 120px;
  height: 120px;
  object-fit: contain;
  display: block;
}

.loading-state {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  isolation: isolate;
}

.loading-gif {
  width: 84px;
  height: 84px;
  object-fit: contain;
  display: block;
  mix-blend-mode: screen;
}

.loader {
  width: 20px;
  height: 20px;
  border: 2px solid #d4cfc9;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.login-page {
  min-height: 100vh;
}

.login-main {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 1.5rem;
}

.login-panel {
  width: min(420px, 100%);
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid rgba(166, 124, 82, 0.14);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.login-title {
  margin: 0 0 1.25rem;
  text-align: center;
  font-size: 1.5rem;
}

.login-submit {
  width: 100%;
  margin-top: 1rem;
}

.user-dialog {
  width: min(520px, calc(100vw - 2rem));
  padding: 0;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
}

.user-dialog::backdrop {
  background: rgba(44, 44, 44, 0.42);
}

.user-dialog-panel {
  background: var(--surface);
  border: 1px solid rgba(166, 124, 82, 0.14);
  border-radius: var(--radius);
  box-shadow: 0 24px 70px rgba(44, 44, 44, 0.22);
  overflow: hidden;
}

.user-form-body {
  display: grid;
  gap: 0.5rem;
  padding: 1.25rem;
}

.user-field-label {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.user-field {
  width: 100%;
  min-height: 44px;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

.password-field {
  position: relative;
  width: 100%;
}

.password-input {
  padding-right: 3rem;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 0.35rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  transform: translateY(-50%);
}

.password-toggle:hover,
.password-toggle.is-visible {
  background: rgba(166, 124, 82, 0.12);
  color: var(--text);
}

.password-toggle:focus-visible {
  outline: 3px solid rgba(166, 124, 82, 0.22);
  outline-offset: 1px;
}

.user-field:focus {
  outline: 3px solid rgba(166, 124, 82, 0.22);
  outline-offset: 1px;
}

.user-form-status {
  padding: 0.75rem;
  border-radius: 8px;
  background: var(--error-bg);
  color: #991b1b;
  font-size: 0.95rem;
}

.user-form-status.success {
  background: var(--success-bg);
  color: #166534;
}

.user-form-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.25rem 1.25rem;
  border-top: 1px solid var(--border);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 960px) {
  .content-grid {
    grid-template-columns: 1fr;
  }

  .guide-section {
    position: static;
  }
}

@media (max-width: 640px) {
  .header-inner {
    padding: calc(1.25rem + env(safe-area-inset-top)) 1rem 1rem;
  }

  .main {
    padding: 0 1rem 1.5rem;
  }

  .upload-zone {
    min-height: 190px;
    padding: 1.5rem;
  }

  .upload-text {
    font-size: 1rem;
  }

  .btn-primary {
    align-self: stretch;
  }

  .filename-copy {
    align-items: stretch;
    flex-direction: column;
  }

  .filename-copy-btn {
    width: 100%;
  }

  .guide-section {
    padding: 1.25rem;
  }

  .briefs-header {
    align-items: stretch;
    flex-direction: column;
    padding: 1rem;
  }

  .briefs-open-btn {
    width: 100%;
  }

  .auth-actions,
  .auth-actions .btn-secondary,
  .user-form-footer,
  .user-form-footer .btn {
    width: 100%;
  }

  .user-form-footer {
    flex-direction: column-reverse;
  }

  .briefs-controls {
    display: grid;
    grid-template-columns: 1fr;
    padding: 1rem;
  }

  .briefs-search,
  .briefs-sort {
    width: 100%;
  }

  .briefs-sort {
    flex: none;
  }

  .brief-row {
    padding: 0.75rem 1rem;
  }

  .briefs-dialog {
    width: calc(100vw - 1rem);
    max-height: calc(100vh - 1rem);
  }

  .briefs-dialog-panel {
    max-height: calc(100vh - 1rem);
  }

  .briefs-dialog-header {
    padding: 1rem;
  }

  .footer {
    padding: 0 1rem calc(1.25rem + env(safe-area-inset-bottom));
  }
}
