*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  font-size: 15px;
  color: #333;
  background: #f0f2f5;
}

/* ===== HEADER ===== */
header {
  background: #1565c0;
  color: white;
  padding: 1.2rem 1rem;
  text-align: center;
}
header h1 { font-size: 1.25rem; font-weight: 700; }
.subtitle { font-size: 0.8rem; opacity: 0.85; margin-top: 0.25rem; }

/* ===== LAYOUT ===== */
.app-layout {
  display: flex;
  gap: 0;
  min-height: calc(100vh - 120px);
}

/* ===== FORM PANEL ===== */
.form-panel {
  width: 320px;
  min-width: 320px;
  background: white;
  border-right: 1px solid #ddd;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  max-height: calc(100vh - 64px);
  position: sticky;
  top: 0;
}

/* ===== TAB BAR ===== */
.tab-bar {
  display: flex;
  border-bottom: 2px solid #e0e0e0;
  overflow-x: auto;
  scrollbar-width: none;
}
.tab-bar::-webkit-scrollbar { display: none; }

.tab-btn {
  flex: 1;
  min-width: 60px;
  padding: 0.6rem 0.25rem;
  font-size: 0.75rem;
  font-weight: 600;
  border: none;
  background: white;
  color: #666;
  cursor: pointer;
  transition: all 0.15s;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  min-height: 44px;
  touch-action: manipulation;
}

.tab-btn.active {
  color: #1565c0;
  border-bottom-color: #1565c0;
}

.tab-content {
  display: none;
  padding: 1rem;
  flex: 1;
  overflow-y: auto;
}
.tab-content.active { display: block; }

.tab-content h2 {
  font-size: 0.9rem;
  color: #1565c0;
  margin-bottom: 0.75rem;
  font-weight: 700;
}

.save-note {
  font-size: 0.72rem;
  color: #888;
  margin-bottom: 0.75rem;
}

/* ===== FORM FIELDS ===== */
label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: #555;
  margin: 0.75rem 0 0.25rem;
}

input[type="text"],
input[type="date"],
input[type="tel"],
input[type="email"],
input[type="url"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 0.5rem 0.6rem;
  font-size: 1rem;
  border: 1.5px solid #ddd;
  border-radius: 6px;
  background: white;
  font-family: inherit;
  -webkit-text-size-adjust: 100%;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #1565c0;
}

textarea { resize: vertical; }

/* ===== CHAR COUNT ===== */
.char-count {
  font-size: 0.72rem;
  color: #999;
  text-align: right;
  margin-top: 0.25rem;
}

/* ===== TAG INPUT ===== */
.tag-input-wrap {
  border: 1.5px solid #ddd;
  border-radius: 6px;
  padding: 0.4rem 0.5rem;
  background: white;
  min-height: 44px;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  align-items: center;
}
.tag-input-wrap:focus-within { border-color: #1565c0; }

.tag-list { display: contents; }

.tag-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  background: #e3f2fd;
  color: #1565c0;
  border-radius: 12px;
  padding: 0.2rem 0.6rem;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.tag-badge button {
  all: unset;
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
  color: #1565c0;
  opacity: 0.7;
  padding: 0 0.15rem;
  min-height: unset;
}
.tag-badge button:hover { opacity: 1; }

.tag-input {
  border: none !important;
  padding: 0.15rem 0.25rem !important;
  font-size: 0.85rem !important;
  flex: 1;
  min-width: 80px;
  background: transparent !important;
}
.tag-input:focus { outline: none; }

/* ===== CHECKBOX GROUP (エンジニア特化) ===== */
.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.6rem;
  margin-bottom: 0.25rem;
  padding: 0.5rem 0.6rem;
  border: 1.5px solid #ddd;
  border-radius: 6px;
  background: white;
}

.cb-label {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: #444;
  cursor: pointer;
  min-height: 28px;
  touch-action: manipulation;
}

.cb-label input[type="checkbox"] {
  width: auto;
  padding: 0;
  border: none;
  accent-color: #1565c0;
}

/* フリーランス案件モード行 */
.freelance-row {
  margin-top: 0.4rem;
}

/* インラインチェック（現在も在籍中） */
.cb-label-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: #444;
  cursor: pointer;
  margin: 0.5rem 0 0.25rem;
  min-height: 28px;
}

.cb-label-inline input[type="checkbox"] {
  width: auto;
  padding: 0;
  border: none;
  accent-color: #1565c0;
}

/* 期間終了日 無効時 */
.period-end-disabled input {
  opacity: 0.4;
}

/* ===== CAREER ENTRY ===== */
.career-entry {
  background: #f9f9f9;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 0.75rem;
  margin-bottom: 0.75rem;
}

.career-entry-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.career-entry-num {
  font-size: 0.78rem;
  font-weight: 700;
  color: #1565c0;
}

.remove-career-btn {
  all: unset;
  cursor: pointer;
  font-size: 0.75rem;
  color: #c62828;
  border: 1px solid #ffcdd2;
  border-radius: 4px;
  padding: 0.2rem 0.5rem;
  background: white;
  min-height: 28px;
  touch-action: manipulation;
}

.career-period {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.3rem;
  align-items: center;
  margin-bottom: 0.25rem;
}

.career-period span {
  text-align: center;
  font-size: 0.78rem;
  color: #666;
}

/* ===== ADD BUTTON ===== */
.add-btn {
  display: block;
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.6rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: #1565c0;
  background: #e3f2fd;
  border: 1.5px dashed #90caf9;
  border-radius: 6px;
  cursor: pointer;
  min-height: 44px;
  touch-action: manipulation;
}
.add-btn:hover { background: #bbdefb; }

/* ===== PREVIEW PANEL ===== */
.preview-panel {
  flex: 1;
  padding: 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.preview-toolbar {
  width: 100%;
  max-width: 794px;
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.print-btn {
  padding: 0.6rem 1.5rem;
  font-size: 0.9rem;
  font-weight: 700;
  background: #1565c0;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  min-height: 44px;
  touch-action: manipulation;
}
.print-btn:hover { background: #1976d2; }

/* ===== RESUME DOCUMENT ===== */
.resume {
  width: 100%;
  max-width: 794px;
  background: white;
  padding: 2.5rem 3rem;
  box-shadow: 0 2px 16px rgba(0,0,0,0.12);
  min-height: 297mm;
}

.resume-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid #1565c0;
  padding-bottom: 0.75rem;
}

.resume-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: #1a237e;
  letter-spacing: 0.1em;
}

.resume-date {
  font-size: 0.82rem;
  color: #666;
  text-align: right;
  white-space: nowrap;
}

/* ===== RESUME SECTION ===== */
.resume-section {
  margin-bottom: 1.5rem;
}

.section-heading {
  font-size: 0.88rem;
  font-weight: 700;
  color: white;
  background: #1565c0;
  padding: 0.3rem 0.75rem;
  margin-bottom: 0.75rem;
  border-radius: 2px;
}

/* ===== INFO TABLE ===== */
.info-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.info-table th {
  background: #f5f5f5;
  color: #555;
  font-weight: 600;
  padding: 0.4rem 0.75rem;
  border: 1px solid #ddd;
  white-space: nowrap;
  width: 18%;
  vertical-align: top;
}

.info-table td {
  padding: 0.4rem 0.75rem;
  border: 1px solid #ddd;
  color: #333;
  vertical-align: top;
  word-break: break-all;
}

/* ===== SUMMARY ===== */
.summary-body {
  font-size: 0.88rem;
  color: #333;
  line-height: 1.8;
  white-space: pre-wrap;
  padding: 0 0.25rem;
}

/* ===== CAREER PREVIEW ===== */
.career-block {
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  margin-bottom: 1rem;
  overflow: hidden;
}

.career-block-head {
  background: #f5f5f5;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid #e0e0e0;
}

.career-company-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: #1a237e;
}

.career-meta {
  font-size: 0.78rem;
  color: #666;
  margin-top: 0.15rem;
}

.career-block-body {
  padding: 0.6rem 0.75rem;
  font-size: 0.85rem;
  color: #333;
}

.career-body-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: #888;
  margin-top: 0.4rem;
  margin-bottom: 0.15rem;
  text-transform: uppercase;
}

.career-body-text {
  white-space: pre-wrap;
  line-height: 1.7;
}

.empty-notice {
  font-size: 0.85rem;
  color: #aaa;
  padding: 0.5rem 0.25rem;
}

/* ===== SKILLS PREVIEW ===== */
.skills-row {
  margin-bottom: 0.75rem;
}

.skills-row-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: #555;
  margin-bottom: 0.3rem;
}

.skills-tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.skill-tag {
  display: inline-block;
  background: #e3f2fd;
  color: #1565c0;
  border-radius: 12px;
  padding: 0.2rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 600;
}

.cert-text {
  font-size: 0.85rem;
  color: #333;
  white-space: pre-wrap;
  line-height: 1.7;
}

/* ===== LINKS ===== */
.links-cell a {
  color: #1565c0;
  font-size: 0.82rem;
  word-break: break-all;
}

/* ===== HOWTO SECTION ===== */
.howto-section {
  max-width: 794px;
  margin: 1.5rem auto;
  padding: 0 1rem;
}

.howto-inner {
  background: white;
  border-radius: 10px;
  padding: 1.5rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.howto-inner h2 {
  font-size: 0.95rem;
  color: #1565c0;
  margin: 1rem 0 0.5rem;
  font-weight: 700;
}
.howto-inner h2:first-child { margin-top: 0; }

.howto-inner ol, .howto-inner p {
  font-size: 0.85rem;
  color: #555;
  line-height: 1.7;
}
.howto-inner ol { padding-left: 1.4rem; }
.howto-inner li { margin-bottom: 0.3rem; }
.howto-inner a { color: #1565c0; }

/* ===== FAQ ===== */
.faq-list {
  margin: 0.25rem 0 0.75rem;
}
.faq-list dt {
  font-size: 0.88rem;
  font-weight: 700;
  color: #1565c0;
  margin: 0.75rem 0 0.2rem;
  padding-left: 0.5rem;
  border-left: 3px solid #1565c0;
}
.faq-list dd {
  font-size: 0.85rem;
  color: #555;
  line-height: 1.7;
  margin: 0 0 0 0.75rem;
}

/* ===== AD UNIT ===== */
.ad-unit {
  min-height: 90px;
  margin: 1.5rem auto;
  max-width: 728px;
  text-align: center;
}

/* ===== AFFILIATE ===== */
.affiliate-block {
  margin: 1rem 0 1.5rem;
  padding: 1rem;
  background: #f9f9f9;
  border-radius: 8px;
  border: 1px solid #e0e0e0;
  text-align: center;
}
.affiliate-label {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
  background: #999;
  padding: 1px 6px;
  border-radius: 3px;
  margin-bottom: 0.5rem;
}
.affiliate-desc {
  font-size: 0.85rem;
  color: #555;
  margin-bottom: 0.75rem;
}
.affiliate-block a {
  font-size: 0.9rem;
  font-weight: 600;
}

/* ===== FOOTER ===== */
footer {
  text-align: center;
  padding: 1.5rem 1rem;
  font-size: 0.82rem;
  color: #888;
}
footer a { color: #666; }

/* ===== PRINT ===== */
@media print {
  .no-print { display: none !important; }

  body { background: white; font-size: 11pt; }

  .app-layout { display: block; }

  .preview-panel {
    padding: 0;
    overflow: visible;
  }

  .resume {
    max-width: 100%;
    box-shadow: none;
    padding: 0;
    min-height: unset;
  }

  .resume-title { font-size: 18pt; }

  .section-heading { font-size: 9pt; }

  .career-block, .info-table, .skills-tag-list { page-break-inside: avoid; }
}

/* ===== MOBILE VIEW BAR ===== */
.mobile-view-bar { display: none; }
.back-to-form-btn { display: none; }

/* ===== MOBILE ===== */
@media (max-width: 700px) {
  .mobile-view-bar {
    display: flex;
    background: #1565c0;
    position: sticky;
    top: 0;
    z-index: 100;
  }

  .mobile-view-btn {
    flex: 1;
    padding: 0.75rem;
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    background: transparent;
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    touch-action: manipulation;
    min-height: 48px;
    transition: all 0.15s;
  }

  .mobile-view-btn.active {
    color: white;
    border-bottom: 3px solid white;
  }

  .back-to-form-btn {
    display: block;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: #1565c0;
    background: #e3f2fd;
    border: 1.5px solid #90caf9;
    border-radius: 6px;
    cursor: pointer;
    touch-action: manipulation;
    min-height: 44px;
  }

  .app-layout { flex-direction: column; }

  .form-panel {
    width: 100%;
    min-width: unset;
    position: static;
    max-height: none;
    border-right: none;
    border-bottom: none;
  }

  .preview-panel {
    display: none;
    padding: 0.75rem 0.5rem;
  }

  /* プレビュー表示時 */
  .app-layout.show-preview .form-panel { display: none; }
  .app-layout.show-preview .preview-panel { display: flex; }

  .resume {
    padding: 1.25rem 0.75rem;
    min-height: unset;
    box-shadow: 0 1px 6px rgba(0,0,0,0.1);
  }

  .resume-title { font-size: 1.2rem; }

  .resume-header {
    flex-direction: column;
    gap: 0.4rem;
    padding-bottom: 0.5rem;
  }

  .resume-date { text-align: left; }

  .info-table th, .info-table td {
    font-size: 0.78rem;
    padding: 0.3rem 0.4rem;
  }

  /* スマホで4列テーブルを2列に */
  .info-table { display: block; overflow-x: auto; }

  .howto-section { padding: 0 0.5rem; }
}
